This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.go
54 lines (50 loc) · 1.68 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
// ServerConfigs Parse Config file export from ShadowsocksX-NG
type ServerConfigs struct {
Configs []Config `json:"configs"`
LocalPort int `json:"local_port"`
}
// Config parsed from exported file.
type Config struct {
Enable bool `json:"enable"`
Password string `json:"password"`
Method string `json:"method"`
Remarks string `json:"remarks"`
Server string `json:"server"`
Obfs string `json:"obfs"`
Protocol string `json:"protocol"`
ServerPort int `json:"server_port"`
RemarkBase64 string `json:"remark_base_64"`
ProtocolParam string `json:"protocolparam"`
ObfsParam string `json:"obfsparam"`
}
// SSLocalConfig Config file content for ss-local command.
type SSLocalConfig struct {
ProtocolParam string `json:"protocol_param"`
Method string `json:"method"`
Protocol string `json:"protocol"`
Server string `json:"server"`
Password string `json:"password"`
LocalAddress string `json:"local_address"`
ServerPort int `json:"server_port"`
Timeout int `json:"timeout"`
LocalPort int `json:"local_port"`
Obfs string `json:"obfs"`
ObfsParam string `json:"obfs_param"`
}
// ToSSLocalConfig Convert Config to SSLocalConfig.
func ToSSLocalConfig(config Config, socksPort int) SSLocalConfig {
return SSLocalConfig{
ProtocolParam: config.ProtocolParam,
Method: config.Method,
Protocol: config.Protocol,
Server: config.Server,
Password: config.Password,
LocalAddress: "0.0.0.0",
ServerPort: config.ServerPort,
Timeout: 60,
LocalPort: socksPort,
Obfs: config.Obfs,
ObfsParam: config.ObfsParam,
}
}