mirror of
				https://github.com/yuezk/GlobalProtect-openconnect.git
				synced 2025-05-20 07:26:58 -04:00 
			
		
		
		
	feat: support the --no-dtls option
				
					
				
			This commit is contained in:
		| @@ -24,6 +24,7 @@ pub(crate) struct ConnectOptions { | ||||
|   pub reconnect_timeout: u32, | ||||
|   pub mtu: u32, | ||||
|   pub disable_ipv6: u32, | ||||
|   pub no_dtls: u32, | ||||
| } | ||||
|  | ||||
| #[link(name = "vpn")] | ||||
|   | ||||
| @@ -63,6 +63,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback) | ||||
|     INFO("RECONNECT_TIMEOUT: %d", options->reconnect_timeout); | ||||
|     INFO("MTU: %d", options->mtu); | ||||
|     INFO("DISABLE_IPV6: %d", options->disable_ipv6); | ||||
|     INFO("NO_DTLS: %d", options->no_dtls); | ||||
|  | ||||
|     vpninfo = openconnect_vpninfo_new(options->user_agent, validate_peer_cert, NULL, NULL, print_progress, NULL); | ||||
|  | ||||
| @@ -119,7 +120,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback) | ||||
|         return 1; | ||||
|     } | ||||
|  | ||||
|     if (openconnect_setup_dtls(vpninfo, 60) != 0) { | ||||
|     if (options->no_dtls || openconnect_setup_dtls(vpninfo, 60) != 0) { | ||||
|         openconnect_disable_dtls(vpninfo); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -25,6 +25,7 @@ typedef struct vpn_options | ||||
|     const int reconnect_timeout; | ||||
|     const int mtu; | ||||
|     const int disable_ipv6; | ||||
|     const int no_dtls; | ||||
| } vpn_options; | ||||
|  | ||||
| int vpn_connect(const vpn_options *options, vpn_connected_callback callback); | ||||
|   | ||||
| @@ -28,6 +28,7 @@ pub struct Vpn { | ||||
|   reconnect_timeout: u32, | ||||
|   mtu: u32, | ||||
|   disable_ipv6: bool, | ||||
|   no_dtls: bool, | ||||
|  | ||||
|   callback: OnConnectedCallback, | ||||
| } | ||||
| @@ -77,6 +78,7 @@ impl Vpn { | ||||
|       reconnect_timeout: self.reconnect_timeout, | ||||
|       mtu: self.mtu, | ||||
|       disable_ipv6: self.disable_ipv6 as u32, | ||||
|       no_dtls: self.no_dtls as u32, | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -125,6 +127,7 @@ pub struct VpnBuilder { | ||||
|   reconnect_timeout: u32, | ||||
|   mtu: u32, | ||||
|   disable_ipv6: bool, | ||||
|   no_dtls: bool, | ||||
| } | ||||
|  | ||||
| impl VpnBuilder { | ||||
| @@ -147,6 +150,7 @@ impl VpnBuilder { | ||||
|       reconnect_timeout: 300, | ||||
|       mtu: 0, | ||||
|       disable_ipv6: false, | ||||
|       no_dtls: false, | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -205,6 +209,11 @@ impl VpnBuilder { | ||||
|     self | ||||
|   } | ||||
|  | ||||
|   pub fn no_dtls(mut self, no_dtls: bool) -> Self { | ||||
|     self.no_dtls = no_dtls; | ||||
|     self | ||||
|   } | ||||
|  | ||||
|   pub fn build(self) -> Result<Vpn, VpnError> { | ||||
|     let script = match self.script { | ||||
|       Some(script) => { | ||||
| @@ -239,6 +248,7 @@ impl VpnBuilder { | ||||
|       reconnect_timeout: self.reconnect_timeout, | ||||
|       mtu: self.mtu, | ||||
|       disable_ipv6: self.disable_ipv6, | ||||
|       no_dtls: self.no_dtls, | ||||
|  | ||||
|       callback: Default::default(), | ||||
|     }) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user