11//extern crate base64;
22use reqwest:: Result ;
33use serde_json:: Value ;
4+ use serde:: { Deserialize , Serialize } ;
45pub fn ascii_to_char ( code : u8 ) -> char {
56 std:: char:: from_u32 ( code as u32 ) . unwrap_or ( '_' )
67}
@@ -55,7 +56,7 @@ enum Tcp {
5556 Ss ,
5657 V2 ,
5758}
58- #[ derive( Clone ) ]
59+ #[ derive( Clone , Serialize , Deserialize ) ]
5960pub struct Information {
6061 pub func : String ,
6162 pub urls : String ,
@@ -94,26 +95,26 @@ impl Information {
9495 }}
9596 }}],
9697 \" outbounds\" :[{{
97- \" protocol\" :{} ,
98+ \" protocol\" :\" {} \" ,
9899 \" sendThrough\" : \" 0.0.0.0\" ,
99100 \" settings\" :{{
100101 \" vnext\" : [{{
101- \" address\" : {} ,
102+ \" address\" : \" {} \" ,
102103 \" port\" :{},
103104 \" users\" :[{{
104- \" alterId\" : {} ,
105- \" id\" :{}
105+ \" alterId\" : \" {} \" ,
106+ \" id\" :\" {} \"
106107 }}]
107108 }}]
108109 }},
109110 \" streamSettings\" :{{
110111 \" dsSettings\" : {{
111- \" path\" : {}
112+ \" path\" : \" {} \"
112113 }},
113114 \" httpSettings\" :{{
114115 \" host\" : [
115116 ],
116- \" path\" :{}
117+ \" path\" :\" {} \"
117118 }},
118119 \" kcpSettings\" : {{
119120 \" congestion\" : false,
@@ -127,7 +128,7 @@ impl Information {
127128 \" uplinkCapacity\" : 5,
128129 \" writeBufferSize\" : 1
129130 }},
130- \" network\" : {} ,
131+ \" network\" : \" {} \" ,
131132 \" quicSettings\" :{{
132133 \" header\" : {{
133134 \" type\" :\" none\"
@@ -168,7 +169,7 @@ impl Information {
168169 \" wsSettings\" :{{
169170 \" headers\" :{{
170171 }},
171- \" path\" :{}
172+ \" path\" :\" {} \"
172173 }},
173174 \" xtlsSettings\" :{{
174175 \" allowInsecure\" :true,
@@ -200,8 +201,8 @@ impl Information {
200201}}" ,
201202 self . func,
202203 self . add,
203- remove_quotation ( self . port. clone( ) ) ,
204- remove_quotation ( self . aid. clone( ) ) ,
204+ self . port. clone( ) ,
205+ self . aid. clone( ) ,
205206 self . id,
206207 self . path,
207208 self . path,
@@ -329,12 +330,12 @@ impl Information {
329330 \" settings\" : {{
330331 \" servers\" :[
331332 {{
332- \" address\" :{} ,
333+ \" address\" :\" {} \" ,
333334 \" email\" : \" \" ,
334335 \" level\" : 0,
335- \" method\" : {} ,
336+ \" method\" : \" {} \" ,
336337 \" ota\" :false,
337- \" password\" :{} ,
338+ \" password\" :\" {} \" ,
338339 \" port\" :{}
339340 }}
340341 ]
@@ -424,7 +425,7 @@ impl Information {
424425 self . add,
425426 self . net,
426427 self . id,
427- remove_quotation ( self . port. clone( ) )
428+ self . port. clone( )
428429 )
429430 }
430431 }
@@ -433,12 +434,12 @@ impl Information {
433434 if self . func == * "\" vmess\" " {
434435 temp. push_str ( & format ! (
435436 "vmess://{}:{}-{}@{}:{}/#{}" ,
436- & remove_quotation ( self . net. clone( ) ) ,
437- & remove_quotation ( self . id. clone( ) ) ,
438- & remove_quotation ( self . aid. clone( ) ) ,
439- & remove_quotation ( self . add. clone( ) ) ,
440- & remove_quotation ( self . port. clone( ) ) ,
441- & remove_quotation ( self . ps. clone( ) )
437+ self . net. clone( ) ,
438+ self . id. clone( ) ,
439+ self . aid. clone( ) ,
440+ self . add. clone( ) ,
441+ self . port. clone( ) ,
442+ self . ps. clone( )
442443 ) )
443444 } else {
444445 temp = self . urls . clone ( ) ;
@@ -448,8 +449,8 @@ impl Information {
448449 pub fn get_the_json_node ( & self ) -> String {
449450 format ! (
450451 "{{
452+ \" urls\" :\" {}\" ,
451453 \" func\" :{},
452- \" url\" :\" {}\" ,
453454 \" add\" :{},
454455 \" aid\" :{},
455456 \" host\" :{},
@@ -459,10 +460,12 @@ impl Information {
459460 \" port\" :{},
460461 \" ps\" :{},
461462 \" tls\" :{},
462- \" type \" :{}
463+ \" typpe \" :{}
463464}},\n " ,
464- self . func ,
465+
465466 self . urls,
467+
468+ self . func,
466469 self . add,
467470 self . aid,
468471 self . host,
0 commit comments