mirror of
https://github.com/xtaci/kcptun.git
synced 2024-04-21 12:32:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3127b2d19f |
+3
-6
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Config for client
|
||||
type Config struct {
|
||||
LocalAddr string `json:"localaddr"`
|
||||
RemoteAddr string `json:"remoteaddr"`
|
||||
@@ -29,16 +30,12 @@ type Config struct {
|
||||
KeepAlive int `json:"keepalive"`
|
||||
}
|
||||
|
||||
func parseJsonConfig(config *Config, path string) error {
|
||||
func parseJSONConfig(config *Config, path string) error {
|
||||
file, err := os.Open(path) // For read access.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if err = json.NewDecoder(file).Decode(config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
return json.NewDecoder(file).Decode(config)
|
||||
}
|
||||
|
||||
+2
-2
@@ -232,7 +232,7 @@ func main() {
|
||||
config.KeepAlive = c.Int("keepalive")
|
||||
|
||||
if c.String("c") != "" {
|
||||
err := parseJsonConfig(&config, c.String("c"))
|
||||
err := parseJSONConfig(&config, c.String("c"))
|
||||
checkError(err)
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ func scavenger(ch chan *smux.Session) {
|
||||
var newList []scavengeSession
|
||||
for k := range sessionList {
|
||||
s := sessionList[k]
|
||||
if s.session.NumStreams() == 0 || s.session.IsClosed() || time.Now().Sub(s.ttl) > maxScavengeTTL {
|
||||
if s.session.NumStreams() == 0 || s.session.IsClosed() || time.Since(s.ttl) > maxScavengeTTL {
|
||||
log.Println("session scavenged")
|
||||
s.session.Close()
|
||||
} else {
|
||||
|
||||
+3
-6
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Config for server
|
||||
type Config struct {
|
||||
Listen string `json:"listen"`
|
||||
Target string `json:"target"`
|
||||
@@ -27,16 +28,12 @@ type Config struct {
|
||||
KeepAlive int `json:"keepalive"`
|
||||
}
|
||||
|
||||
func parseJsonConfig(config *Config, path string) error {
|
||||
func parseJSONConfig(config *Config, path string) error {
|
||||
file, err := os.Open(path) // For read access.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if err = json.NewDecoder(file).Decode(config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
return json.NewDecoder(file).Decode(config)
|
||||
}
|
||||
|
||||
+1
-1
@@ -254,7 +254,7 @@ func main() {
|
||||
|
||||
if c.String("c") != "" {
|
||||
//Now only support json config file
|
||||
err := parseJsonConfig(&config, c.String("c"))
|
||||
err := parseJSONConfig(&config, c.String("c"))
|
||||
checkError(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user