@@ -7,6 +7,7 @@ use crate::config::Config;
77use crate :: template:: Template ;
88
99pub const URL_GET_COMPANY : & str = "https://corplink.volcengine.cn/api/match" ;
10+ pub ( crate ) const CORPLINK_APP_VERSION : & str = "201000" ;
1011
1112const URL_GET_LOGIN_METHOD : & str = "{{url}}/api/login/setting?os={{os}}&os_version={{version}}" ;
1213const URL_GET_TPS_LOGIN_METHOD : & str = "{{url}}/api/tpslogin/link?os={{os}}&os_version={{version}}" ;
@@ -18,7 +19,8 @@ const URL_VERIFY_CODE: &str = "{{url}}/api/login/code/verify?os={{os}}&os_versio
1819const URL_LOGIN_PASSWORD : & str = "{{url}}/api/login?os={{os}}&os_version={{version}}" ;
1920const URL_LOGIN_PASSWORD_V1 : & str =
2021 "{{url}}/api/v1/login?os={{os}}&os_version={{version}}&client_source=FeiLian" ;
21- const URL_LIST_VPN : & str = "{{url}}/api/vpn/list?os={{os}}&os_version={{version}}" ;
22+ const URL_LIST_VPN : & str =
23+ "{{url}}/api/vpn/list?os={{os}}&os_version={{version}}&app_version={{app_version}}" ;
2224
2325const URL_PING_VPN_HOST : & str = "{{url}}/vpn/ping?os={{os}}&os_version={{version}}" ;
2426const URL_FETCH_PEER_INFO : & str = "{{url}}/vpn/conn?os={{os}}&os_version={{version}}" ;
@@ -54,6 +56,7 @@ struct UserUrlParam {
5456 url : String ,
5557 os : String ,
5658 version : String ,
59+ app_version : String ,
5760}
5861
5962#[ derive( Clone , Serialize ) ]
@@ -112,6 +115,7 @@ impl ApiUrl {
112115 . context ( "server url missing in config" ) ?,
113116 os : os. clone ( ) ,
114117 version : version. clone ( ) ,
118+ app_version : CORPLINK_APP_VERSION . to_string ( ) ,
115119 } ,
116120 vpn_param : VpnUrlParam {
117121 url : "" . to_string ( ) ,
@@ -145,3 +149,27 @@ impl ApiUrl {
145149 }
146150 }
147151}
152+
153+ #[ cfg( test) ]
154+ mod tests {
155+ use serde_json:: json;
156+
157+ use super :: * ;
158+
159+ #[ test]
160+ fn list_vpn_url_includes_app_version ( ) {
161+ let conf: Config = serde_json:: from_value ( json ! ( {
162+ "company_name" : "test" ,
163+ "username" : "test" ,
164+ "server" : "https://vpn.example.com"
165+ } ) )
166+ . unwrap ( ) ;
167+
168+ let api_url = ApiUrl :: new ( & conf) . unwrap ( ) ;
169+
170+ assert_eq ! (
171+ api_url. get_api_url( & ApiName :: ListVPN ) ,
172+ "https://vpn.example.com/api/vpn/list?os=Android&os_version=2&app_version=201000"
173+ ) ;
174+ }
175+ }
0 commit comments