@@ -49,16 +49,16 @@ public bool Stop()
4949 return ! _isRunning ;
5050 }
5151
52- public bool SetProxyConfig ( string type , string ip , ushort port )
52+ public bool SetProxyConfig ( string type , string ip , ushort port , string username , string password )
5353 {
5454 var proxyType = type . ToUpper ( ) == "HTTP"
5555 ? ProxyBridgeNative . ProxyType . HTTP
5656 : ProxyBridgeNative . ProxyType . SOCKS5 ;
5757
58- return ProxyBridgeNative . ProxyBridge_SetProxyConfig ( proxyType , ip , port ) ;
58+ return ProxyBridgeNative . ProxyBridge_SetProxyConfig ( proxyType , ip , port , username , password ) ;
5959 }
6060
61- public uint AddRule ( string processName , string action )
61+ public uint AddRule ( string processName , string targetHosts , string targetPorts , string protocol , string action )
6262 {
6363 var ruleAction = action . ToUpper ( ) switch
6464 {
@@ -67,7 +67,15 @@ public uint AddRule(string processName, string action)
6767 _ => ProxyBridgeNative . RuleAction . PROXY
6868 } ;
6969
70- return ProxyBridgeNative . ProxyBridge_AddRule ( processName , ruleAction ) ;
70+ var ruleProtocol = protocol . ToUpper ( ) switch
71+ {
72+ "UDP" => ProxyBridgeNative . RuleProtocol . UDP ,
73+ "BOTH" => ProxyBridgeNative . RuleProtocol . BOTH ,
74+ "TCP+UDP" => ProxyBridgeNative . RuleProtocol . BOTH ,
75+ _ => ProxyBridgeNative . RuleProtocol . TCP
76+ } ;
77+
78+ return ProxyBridgeNative . ProxyBridge_AddRule ( processName , targetHosts , targetPorts , ruleProtocol , ruleAction ) ;
7179 }
7280
7381 public bool EnableRule ( uint ruleId )
@@ -80,9 +88,46 @@ public bool DisableRule(uint ruleId)
8088 return ProxyBridgeNative . ProxyBridge_DisableRule ( ruleId ) ;
8189 }
8290
83- public bool ClearRules ( )
91+ public bool DeleteRule ( uint ruleId )
92+ {
93+ return ProxyBridgeNative . ProxyBridge_DeleteRule ( ruleId ) ;
94+ }
95+
96+ public bool EditRule ( uint ruleId , string processName , string targetHosts , string targetPorts , string protocol , string action )
97+ {
98+ var ruleAction = action . ToUpper ( ) switch
99+ {
100+ "DIRECT" => ProxyBridgeNative . RuleAction . DIRECT ,
101+ "BLOCK" => ProxyBridgeNative . RuleAction . BLOCK ,
102+ _ => ProxyBridgeNative . RuleAction . PROXY
103+ } ;
104+
105+ var ruleProtocol = protocol . ToUpper ( ) switch
106+ {
107+ "UDP" => ProxyBridgeNative . RuleProtocol . UDP ,
108+ "BOTH" => ProxyBridgeNative . RuleProtocol . BOTH ,
109+ "TCP+UDP" => ProxyBridgeNative . RuleProtocol . BOTH ,
110+ _ => ProxyBridgeNative . RuleProtocol . TCP
111+ } ;
112+
113+ return ProxyBridgeNative . ProxyBridge_EditRule ( ruleId , processName , targetHosts , targetPorts , ruleProtocol , ruleAction ) ;
114+ }
115+
116+ public void SetDnsViaProxy ( bool enable )
117+ {
118+ ProxyBridgeNative . ProxyBridge_SetDnsViaProxy ( enable ) ;
119+ }
120+
121+ public string TestConnection ( string targetHost , ushort targetPort )
84122 {
85- return ProxyBridgeNative . ProxyBridge_ClearRules ( ) ;
123+ var buffer = new System . Text . StringBuilder ( 4096 ) ;
124+ int result = ProxyBridgeNative . ProxyBridge_TestConnection (
125+ targetHost ,
126+ targetPort ,
127+ buffer ,
128+ ( UIntPtr ) buffer . Capacity ) ;
129+
130+ return buffer . ToString ( ) ;
86131 }
87132
88133 public void Dispose ( )
0 commit comments