|
|
@@ -32,6 +32,13 @@ const (
|
|
32
|
32
|
SecretModeTLS
|
|
33
|
33
|
)
|
|
34
|
34
|
|
|
|
35
|
+type PreferIP uint8
|
|
|
36
|
+
|
|
|
37
|
+const (
|
|
|
38
|
+ PreferIPv4 PreferIP = iota
|
|
|
39
|
+ PreferIPv6
|
|
|
40
|
+)
|
|
|
41
|
+
|
|
35
|
42
|
const SimpleSecretLength = 16
|
|
36
|
43
|
|
|
37
|
44
|
type OptionType uint8
|
|
|
@@ -40,6 +47,8 @@ const (
|
|
40
|
47
|
OptionTypeDebug OptionType = iota
|
|
41
|
48
|
OptionTypeVerbose
|
|
42
|
49
|
|
|
|
50
|
+ OptionTypePreferIP
|
|
|
51
|
+
|
|
43
|
52
|
OptionTypeBind
|
|
44
|
53
|
OptionTypePublicIPv4
|
|
45
|
54
|
OptionTypePublicIPv6
|
|
|
@@ -86,6 +95,7 @@ type Config struct {
|
|
86
|
95
|
Debug bool `json:"debug"`
|
|
87
|
96
|
Verbose bool `json:"verbose"`
|
|
88
|
97
|
SecretMode SecretMode `json:"secret_mode"`
|
|
|
98
|
+ PreferIP PreferIP `json:"prefer_ip"`
|
|
89
|
99
|
|
|
90
|
100
|
Secret []byte `json:"secret"`
|
|
91
|
101
|
AdTag []byte `json:"adtag"`
|
|
|
@@ -105,6 +115,16 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen
|
|
105
|
115
|
C.Debug = opt.Value.(bool)
|
|
106
|
116
|
case OptionTypeVerbose:
|
|
107
|
117
|
C.Verbose = opt.Value.(bool)
|
|
|
118
|
+ case OptionTypePreferIP:
|
|
|
119
|
+ value := opt.Value.(string)
|
|
|
120
|
+ switch value {
|
|
|
121
|
+ case "ipv4":
|
|
|
122
|
+ C.PreferIP = PreferIPv4
|
|
|
123
|
+ case "ipv6":
|
|
|
124
|
+ C.PreferIP = PreferIPv6
|
|
|
125
|
+ default:
|
|
|
126
|
+ return fmt.Errorf("incorrect direct IP mode %s", value)
|
|
|
127
|
+ }
|
|
108
|
128
|
case OptionTypeBind:
|
|
109
|
129
|
C.Bind = opt.Value.(*net.TCPAddr)
|
|
110
|
130
|
case OptionTypePublicIPv4:
|