@@ -16,15 +16,15 @@ public class VMessController
16
16
/// <summary>
17
17
/// 当前状态
18
18
/// </summary>
19
- public Objects . State State = Objects . State . Waiting ;
19
+ public Models . State State = Models . State . Waiting ;
20
20
21
21
/// <summary>
22
22
/// 启动
23
23
/// </summary>
24
24
/// <param name="server">服务器</param>
25
25
/// <param name="mode">模式</param>
26
26
/// <returns>是否启动成功</returns>
27
- public bool Start ( Objects . Server server , Objects . Mode mode )
27
+ public bool Start ( Models . Server server , Models . Mode mode )
28
28
{
29
29
if ( ! File . Exists ( "bin\\ v2ray.exe" ) || ! File . Exists ( "bin\\ v2ctl.exe" ) )
30
30
{
@@ -36,32 +36,32 @@ public bool Start(Objects.Server server, Objects.Mode mode)
36
36
Directory . CreateDirectory ( "data" ) ;
37
37
}
38
38
39
- File . WriteAllText ( "data\\ last.json" , Newtonsoft . Json . JsonConvert . SerializeObject ( new Objects . Information . VMess . Config ( )
39
+ File . WriteAllText ( "data\\ last.json" , Newtonsoft . Json . JsonConvert . SerializeObject ( new Models . Information . VMess . Config ( )
40
40
{
41
- inbounds = new List < Objects . Information . VMess . Inbounds > ( )
41
+ inbounds = new List < Models . Information . VMess . Inbounds > ( )
42
42
{
43
- new Objects . Information . VMess . Inbounds ( )
43
+ new Models . Information . VMess . Inbounds ( )
44
44
{
45
- settings = new Objects . Information . VMess . InboundSettings ( ) ,
45
+ settings = new Models . Information . VMess . InboundSettings ( ) ,
46
46
port = Global . Settings . Socks5LocalPort ,
47
47
listen = Global . Settings . LocalAddress
48
48
}
49
49
} ,
50
- outbounds = new List < Objects . Information . VMess . Outbounds > ( )
50
+ outbounds = new List < Models . Information . VMess . Outbounds > ( )
51
51
{
52
- new Objects . Information . VMess . Outbounds ( )
52
+ new Models . Information . VMess . Outbounds ( )
53
53
{
54
- settings = new Objects . Information . VMess . OutboundSettings ( )
54
+ settings = new Models . Information . VMess . OutboundSettings ( )
55
55
{
56
- vnext = new List < Objects . Information . VMess . VNext > ( )
56
+ vnext = new List < Models . Information . VMess . VNext > ( )
57
57
{
58
- new Objects . Information . VMess . VNext ( )
58
+ new Models . Information . VMess . VNext ( )
59
59
{
60
60
address = server . Address ,
61
61
port = server . Port ,
62
- users = new List < Objects . Information . VMess . User >
62
+ users = new List < Models . Information . VMess . User >
63
63
{
64
- new Objects . Information . VMess . User ( )
64
+ new Models . Information . VMess . User ( )
65
65
{
66
66
id = server . UserID ,
67
67
alterId = server . AlterID ,
@@ -71,59 +71,59 @@ public bool Start(Objects.Server server, Objects.Mode mode)
71
71
}
72
72
}
73
73
} ,
74
- streamSettings = new Objects . Information . VMess . StreamSettings ( )
74
+ streamSettings = new Models . Information . VMess . StreamSettings ( )
75
75
{
76
76
network = server . TransferProtocol ,
77
77
security = server . TLSSecure == true ? "tls" : "" ,
78
- wsSettings = server . TransferProtocol == "ws" ? new Objects . Information . VMess . WebSocketSettings ( )
78
+ wsSettings = server . TransferProtocol == "ws" ? new Models . Information . VMess . WebSocketSettings ( )
79
79
{
80
80
path = server . Path == "" ? "/" : server . Path ,
81
- headers = new Objects . Information . VMess . WSHeaders ( )
81
+ headers = new Models . Information . VMess . WSHeaders ( )
82
82
{
83
83
Host = server . Host == "" ? server . Address : server . Host
84
84
}
85
85
} : null ,
86
- tcpSettings = server . FakeType == "http" ? new Objects . Information . VMess . TCPSettings ( )
86
+ tcpSettings = server . FakeType == "http" ? new Models . Information . VMess . TCPSettings ( )
87
87
{
88
- header = new Objects . Information . VMess . TCPHeaders ( )
88
+ header = new Models . Information . VMess . TCPHeaders ( )
89
89
{
90
90
type = server . FakeType ,
91
- request = new Objects . Information . VMess . TCPRequest ( )
91
+ request = new Models . Information . VMess . TCPRequest ( )
92
92
{
93
93
path = server . Path == "" ? "/" : server . Path ,
94
- headers = new Objects . Information . VMess . TCPRequestHeaders ( )
94
+ headers = new Models . Information . VMess . TCPRequestHeaders ( )
95
95
{
96
96
Host = server . Host == "" ? server . Address : server . Host
97
97
}
98
98
}
99
99
}
100
100
} : null ,
101
- kcpSettings = server . TransferProtocol == "kcp" ? new Objects . Information . VMess . KCPSettings ( )
101
+ kcpSettings = server . TransferProtocol == "kcp" ? new Models . Information . VMess . KCPSettings ( )
102
102
{
103
- header = new Objects . Information . VMess . TCPHeaders ( )
103
+ header = new Models . Information . VMess . TCPHeaders ( )
104
104
{
105
105
type = server . FakeType
106
106
}
107
107
} : null ,
108
- quicSettings = server . TransferProtocol == "quic" ? new Objects . Information . VMess . QUICSettings ( )
108
+ quicSettings = server . TransferProtocol == "quic" ? new Models . Information . VMess . QUICSettings ( )
109
109
{
110
110
security = server . QUICSecurity ,
111
111
key = server . QUICSecret ,
112
- header = new Objects . Information . VMess . TCPHeaders ( )
112
+ header = new Models . Information . VMess . TCPHeaders ( )
113
113
{
114
114
type = server . FakeType
115
115
}
116
116
} : null ,
117
- httpSettings = server . TransferProtocol == "h2" ? new Objects . Information . VMess . HTTPSettings ( )
117
+ httpSettings = server . TransferProtocol == "h2" ? new Models . Information . VMess . HTTPSettings ( )
118
118
{
119
119
host = server . Host == "" ? server . Address : server . Host ,
120
120
path = server . Path == "" ? "/" : server . Path
121
121
} : null ,
122
- tlsSettings = new Objects . Information . VMess . TLSSettings ( )
122
+ tlsSettings = new Models . Information . VMess . TLSSettings ( )
123
123
} ,
124
- mux = new Objects . Information . VMess . OutboundMux ( )
124
+ mux = new Models . Information . VMess . OutboundMux ( )
125
125
} ,
126
- new Objects . Information . VMess . Outbounds ( )
126
+ new Models . Information . VMess . Outbounds ( )
127
127
{
128
128
tag = "direct" ,
129
129
protocol = "freedom" ,
@@ -132,11 +132,11 @@ public bool Start(Objects.Server server, Objects.Mode mode)
132
132
mux = null
133
133
}
134
134
} ,
135
- routing = new Objects . Information . VMess . Routing ( )
135
+ routing = new Models . Information . VMess . Routing ( )
136
136
{
137
- rules = new List < Objects . Information . VMess . RoutingRules > ( )
137
+ rules = new List < Models . Information . VMess . RoutingRules > ( )
138
138
{
139
- mode . BypassChina == true ? new Objects . Information . VMess . RoutingRules ( )
139
+ mode . BypassChina == true ? new Models . Information . VMess . RoutingRules ( )
140
140
{
141
141
type = "field" ,
142
142
ip = new List < string >
@@ -150,7 +150,7 @@ public bool Start(Objects.Server server, Objects.Mode mode)
150
150
"geosite:cn"
151
151
} ,
152
152
outboundTag = "direct"
153
- } : new Objects . Information . VMess . RoutingRules ( )
153
+ } : new Models . Information . VMess . RoutingRules ( )
154
154
{
155
155
type = "field" ,
156
156
ip = new List < string >
@@ -179,15 +179,15 @@ public bool Start(Objects.Server server, Objects.Mode mode)
179
179
Instance . OutputDataReceived += OnOutputDataReceived ;
180
180
Instance . ErrorDataReceived += OnOutputDataReceived ;
181
181
182
- State = Objects . State . Starting ;
182
+ State = Models . State . Starting ;
183
183
Instance . Start ( ) ;
184
184
Instance . BeginOutputReadLine ( ) ;
185
185
Instance . BeginErrorReadLine ( ) ;
186
186
for ( int i = 0 ; i < 1000 ; i ++ )
187
187
{
188
188
Thread . Sleep ( 10 ) ;
189
189
190
- if ( State == Objects . State . Started )
190
+ if ( State == Models . State . Started )
191
191
{
192
192
if ( File . Exists ( "data\\ last.json" ) )
193
193
{
@@ -196,7 +196,7 @@ public bool Start(Objects.Server server, Objects.Mode mode)
196
196
return true ;
197
197
}
198
198
199
- if ( State == Objects . State . Stopped )
199
+ if ( State == Models . State . Stopped )
200
200
{
201
201
Utils . Logging . Info ( "V2Ray 进程启动失败" ) ;
202
202
@@ -234,19 +234,19 @@ public void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
234
234
{
235
235
File . AppendAllText ( "logging\\ v2ray.log" , $ "{ e . Data } \r \n ") ;
236
236
237
- if ( State == Objects . State . Starting )
237
+ if ( State == Models . State . Starting )
238
238
{
239
239
if ( Instance . HasExited )
240
240
{
241
- State = Objects . State . Stopped ;
241
+ State = Models . State . Stopped ;
242
242
}
243
243
else if ( e . Data . Contains ( "started" ) )
244
244
{
245
- State = Objects . State . Started ;
245
+ State = Models . State . Started ;
246
246
}
247
247
else if ( e . Data . Contains ( "config file not readable" ) || e . Data . Contains ( "failed to" ) )
248
248
{
249
- State = Objects . State . Stopped ;
249
+ State = Models . State . Stopped ;
250
250
}
251
251
}
252
252
}
0 commit comments