client_test.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. // Copyright 2020 The frp Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package config
  15. import (
  16. "testing"
  17. "github.com/stretchr/testify/assert"
  18. "github.com/fatedier/frp/pkg/auth"
  19. "github.com/fatedier/frp/pkg/consts"
  20. )
  21. const (
  22. testUser = "test"
  23. )
  24. var testClientBytesWithFull = []byte(`
  25. # [common] is integral section
  26. [common]
  27. server_addr = 0.0.0.9
  28. server_port = 7009
  29. http_proxy = http://user:passwd@192.168.1.128:8080
  30. log_file = ./frpc.log9
  31. log_way = file
  32. log_level = info9
  33. log_max_days = 39
  34. disable_log_color = false
  35. authenticate_heartbeats = false
  36. authenticate_new_work_conns = false
  37. token = 12345678
  38. oidc_client_id = client-id
  39. oidc_client_secret = client-secret
  40. oidc_audience = audience
  41. oidc_token_endpoint_url = endpoint_url
  42. admin_addr = 127.0.0.9
  43. admin_port = 7409
  44. admin_user = admin9
  45. admin_pwd = admin9
  46. assets_dir = ./static9
  47. pool_count = 59
  48. tcp_mux
  49. user = your_name
  50. login_fail_exit
  51. protocol = tcp
  52. tls_enable = true
  53. tls_cert_file = client.crt
  54. tls_key_file = client.key
  55. tls_trusted_ca_file = ca.crt
  56. tls_server_name = example.com
  57. dns_server = 8.8.8.9
  58. start = ssh,dns
  59. heartbeat_interval = 39
  60. heartbeat_timeout = 99
  61. meta_var1 = 123
  62. meta_var2 = 234
  63. udp_packet_size = 1509
  64. # all proxy
  65. [ssh]
  66. type = tcp
  67. local_ip = 127.0.0.9
  68. local_port = 29
  69. bandwidth_limit = 19MB
  70. bandwidth_limit_mode = server
  71. use_encryption
  72. use_compression
  73. remote_port = 6009
  74. group = test_group
  75. group_key = 123456
  76. health_check_type = tcp
  77. health_check_timeout_s = 3
  78. health_check_max_failed = 3
  79. health_check_interval_s = 19
  80. meta_var1 = 123
  81. meta_var2 = 234
  82. [ssh_random]
  83. type = tcp
  84. local_ip = 127.0.0.9
  85. local_port = 29
  86. remote_port = 9
  87. [range:tcp_port]
  88. type = tcp
  89. local_ip = 127.0.0.9
  90. local_port = 6010-6011,6019
  91. remote_port = 6010-6011,6019
  92. use_encryption = false
  93. use_compression = false
  94. [dns]
  95. type = udp
  96. local_ip = 114.114.114.114
  97. local_port = 59
  98. remote_port = 6009
  99. use_encryption
  100. use_compression
  101. [range:udp_port]
  102. type = udp
  103. local_ip = 114.114.114.114
  104. local_port = 6000,6010-6011
  105. remote_port = 6000,6010-6011
  106. use_encryption
  107. use_compression
  108. [web01]
  109. type = http
  110. local_ip = 127.0.0.9
  111. local_port = 89
  112. use_encryption
  113. use_compression
  114. http_user = admin
  115. http_pwd = admin
  116. subdomain = web01
  117. custom_domains = web02.yourdomain.com
  118. locations = /,/pic
  119. host_header_rewrite = example.com
  120. header_X-From-Where = frp
  121. health_check_type = http
  122. health_check_url = /status
  123. health_check_interval_s = 19
  124. health_check_max_failed = 3
  125. health_check_timeout_s = 3
  126. [web02]
  127. type = https
  128. local_ip = 127.0.0.9
  129. local_port = 8009
  130. use_encryption
  131. use_compression
  132. subdomain = web01
  133. custom_domains = web02.yourdomain.com
  134. proxy_protocol_version = v2
  135. [secret_tcp]
  136. type = stcp
  137. sk = abcdefg
  138. local_ip = 127.0.0.1
  139. local_port = 22
  140. use_encryption = false
  141. use_compression = false
  142. [p2p_tcp]
  143. type = xtcp
  144. sk = abcdefg
  145. local_ip = 127.0.0.1
  146. local_port = 22
  147. use_encryption = false
  148. use_compression = false
  149. [tcpmuxhttpconnect]
  150. type = tcpmux
  151. multiplexer = httpconnect
  152. local_ip = 127.0.0.1
  153. local_port = 10701
  154. custom_domains = tunnel1
  155. [plugin_unix_domain_socket]
  156. type = tcp
  157. remote_port = 6003
  158. plugin = unix_domain_socket
  159. plugin_unix_path = /var/run/docker.sock
  160. [plugin_http_proxy]
  161. type = tcp
  162. remote_port = 6004
  163. plugin = http_proxy
  164. plugin_http_user = abc
  165. plugin_http_passwd = abc
  166. [plugin_socks5]
  167. type = tcp
  168. remote_port = 6005
  169. plugin = socks5
  170. plugin_user = abc
  171. plugin_passwd = abc
  172. [plugin_static_file]
  173. type = tcp
  174. remote_port = 6006
  175. plugin = static_file
  176. plugin_local_path = /var/www/blog
  177. plugin_strip_prefix = static
  178. plugin_http_user = abc
  179. plugin_http_passwd = abc
  180. [plugin_https2http]
  181. type = https
  182. custom_domains = test.yourdomain.com
  183. plugin = https2http
  184. plugin_local_addr = 127.0.0.1:80
  185. plugin_crt_path = ./server.crt
  186. plugin_key_path = ./server.key
  187. plugin_host_header_rewrite = 127.0.0.1
  188. plugin_header_X-From-Where = frp
  189. [plugin_http2https]
  190. type = http
  191. custom_domains = test.yourdomain.com
  192. plugin = http2https
  193. plugin_local_addr = 127.0.0.1:443
  194. plugin_host_header_rewrite = 127.0.0.1
  195. plugin_header_X-From-Where = frp
  196. # visitor
  197. [secret_tcp_visitor]
  198. role = visitor
  199. type = stcp
  200. server_name = secret_tcp
  201. sk = abcdefg
  202. bind_addr = 127.0.0.1
  203. bind_port = 9000
  204. use_encryption = false
  205. use_compression = false
  206. [p2p_tcp_visitor]
  207. role = visitor
  208. type = xtcp
  209. server_name = p2p_tcp
  210. sk = abcdefg
  211. bind_addr = 127.0.0.1
  212. bind_port = 9001
  213. use_encryption = false
  214. use_compression = false
  215. `)
  216. func Test_LoadClientCommonConf(t *testing.T) {
  217. assert := assert.New(t)
  218. expected := ClientCommonConf{
  219. ClientConfig: auth.ClientConfig{
  220. BaseConfig: auth.BaseConfig{
  221. AuthenticationMethod: "token",
  222. AuthenticateHeartBeats: false,
  223. AuthenticateNewWorkConns: false,
  224. },
  225. TokenConfig: auth.TokenConfig{
  226. Token: "12345678",
  227. },
  228. OidcClientConfig: auth.OidcClientConfig{
  229. OidcClientID: "client-id",
  230. OidcClientSecret: "client-secret",
  231. OidcAudience: "audience",
  232. OidcTokenEndpointURL: "endpoint_url",
  233. },
  234. },
  235. ServerAddr: "0.0.0.9",
  236. ServerPort: 7009,
  237. NatHoleSTUNServer: "stun.easyvoip.com:3478",
  238. DialServerTimeout: 10,
  239. DialServerKeepAlive: 7200,
  240. HTTPProxy: "http://user:passwd@192.168.1.128:8080",
  241. LogFile: "./frpc.log9",
  242. LogWay: "file",
  243. LogLevel: "info9",
  244. LogMaxDays: 39,
  245. DisableLogColor: false,
  246. AdminAddr: "127.0.0.9",
  247. AdminPort: 7409,
  248. AdminUser: "admin9",
  249. AdminPwd: "admin9",
  250. AssetsDir: "./static9",
  251. PoolCount: 59,
  252. TCPMux: true,
  253. TCPMuxKeepaliveInterval: 60,
  254. User: "your_name",
  255. LoginFailExit: true,
  256. Protocol: "tcp",
  257. QUICKeepalivePeriod: 10,
  258. QUICMaxIdleTimeout: 30,
  259. QUICMaxIncomingStreams: 100000,
  260. TLSEnable: true,
  261. TLSCertFile: "client.crt",
  262. TLSKeyFile: "client.key",
  263. TLSTrustedCaFile: "ca.crt",
  264. TLSServerName: "example.com",
  265. DNSServer: "8.8.8.9",
  266. Start: []string{"ssh", "dns"},
  267. HeartbeatInterval: 39,
  268. HeartbeatTimeout: 99,
  269. Metas: map[string]string{
  270. "var1": "123",
  271. "var2": "234",
  272. },
  273. UDPPacketSize: 1509,
  274. IncludeConfigFiles: []string{},
  275. }
  276. common, err := UnmarshalClientConfFromIni(testClientBytesWithFull)
  277. assert.NoError(err)
  278. assert.EqualValues(expected, common)
  279. }
  280. func Test_LoadClientBasicConf(t *testing.T) {
  281. assert := assert.New(t)
  282. proxyExpected := map[string]ProxyConf{
  283. testUser + ".ssh": &TCPProxyConf{
  284. BaseProxyConf: BaseProxyConf{
  285. ProxyName: testUser + ".ssh",
  286. ProxyType: consts.TCPProxy,
  287. UseCompression: true,
  288. UseEncryption: true,
  289. Group: "test_group",
  290. GroupKey: "123456",
  291. BandwidthLimit: MustBandwidthQuantity("19MB"),
  292. BandwidthLimitMode: BandwidthLimitModeServer,
  293. Metas: map[string]string{
  294. "var1": "123",
  295. "var2": "234",
  296. },
  297. LocalSvrConf: LocalSvrConf{
  298. LocalIP: "127.0.0.9",
  299. LocalPort: 29,
  300. },
  301. HealthCheckConf: HealthCheckConf{
  302. HealthCheckType: consts.TCPProxy,
  303. HealthCheckTimeoutS: 3,
  304. HealthCheckMaxFailed: 3,
  305. HealthCheckIntervalS: 19,
  306. HealthCheckAddr: "127.0.0.9:29",
  307. },
  308. },
  309. RemotePort: 6009,
  310. },
  311. testUser + ".ssh_random": &TCPProxyConf{
  312. BaseProxyConf: BaseProxyConf{
  313. ProxyName: testUser + ".ssh_random",
  314. ProxyType: consts.TCPProxy,
  315. LocalSvrConf: LocalSvrConf{
  316. LocalIP: "127.0.0.9",
  317. LocalPort: 29,
  318. },
  319. BandwidthLimitMode: BandwidthLimitModeClient,
  320. },
  321. RemotePort: 9,
  322. },
  323. testUser + ".tcp_port_0": &TCPProxyConf{
  324. BaseProxyConf: BaseProxyConf{
  325. ProxyName: testUser + ".tcp_port_0",
  326. ProxyType: consts.TCPProxy,
  327. LocalSvrConf: LocalSvrConf{
  328. LocalIP: "127.0.0.9",
  329. LocalPort: 6010,
  330. },
  331. BandwidthLimitMode: BandwidthLimitModeClient,
  332. },
  333. RemotePort: 6010,
  334. },
  335. testUser + ".tcp_port_1": &TCPProxyConf{
  336. BaseProxyConf: BaseProxyConf{
  337. ProxyName: testUser + ".tcp_port_1",
  338. ProxyType: consts.TCPProxy,
  339. LocalSvrConf: LocalSvrConf{
  340. LocalIP: "127.0.0.9",
  341. LocalPort: 6011,
  342. },
  343. BandwidthLimitMode: BandwidthLimitModeClient,
  344. },
  345. RemotePort: 6011,
  346. },
  347. testUser + ".tcp_port_2": &TCPProxyConf{
  348. BaseProxyConf: BaseProxyConf{
  349. ProxyName: testUser + ".tcp_port_2",
  350. ProxyType: consts.TCPProxy,
  351. LocalSvrConf: LocalSvrConf{
  352. LocalIP: "127.0.0.9",
  353. LocalPort: 6019,
  354. },
  355. BandwidthLimitMode: BandwidthLimitModeClient,
  356. },
  357. RemotePort: 6019,
  358. },
  359. testUser + ".dns": &UDPProxyConf{
  360. BaseProxyConf: BaseProxyConf{
  361. ProxyName: testUser + ".dns",
  362. ProxyType: consts.UDPProxy,
  363. UseEncryption: true,
  364. UseCompression: true,
  365. LocalSvrConf: LocalSvrConf{
  366. LocalIP: "114.114.114.114",
  367. LocalPort: 59,
  368. },
  369. BandwidthLimitMode: BandwidthLimitModeClient,
  370. },
  371. RemotePort: 6009,
  372. },
  373. testUser + ".udp_port_0": &UDPProxyConf{
  374. BaseProxyConf: BaseProxyConf{
  375. ProxyName: testUser + ".udp_port_0",
  376. ProxyType: consts.UDPProxy,
  377. UseEncryption: true,
  378. UseCompression: true,
  379. LocalSvrConf: LocalSvrConf{
  380. LocalIP: "114.114.114.114",
  381. LocalPort: 6000,
  382. },
  383. BandwidthLimitMode: BandwidthLimitModeClient,
  384. },
  385. RemotePort: 6000,
  386. },
  387. testUser + ".udp_port_1": &UDPProxyConf{
  388. BaseProxyConf: BaseProxyConf{
  389. ProxyName: testUser + ".udp_port_1",
  390. ProxyType: consts.UDPProxy,
  391. UseEncryption: true,
  392. UseCompression: true,
  393. LocalSvrConf: LocalSvrConf{
  394. LocalIP: "114.114.114.114",
  395. LocalPort: 6010,
  396. },
  397. BandwidthLimitMode: BandwidthLimitModeClient,
  398. },
  399. RemotePort: 6010,
  400. },
  401. testUser + ".udp_port_2": &UDPProxyConf{
  402. BaseProxyConf: BaseProxyConf{
  403. ProxyName: testUser + ".udp_port_2",
  404. ProxyType: consts.UDPProxy,
  405. UseEncryption: true,
  406. UseCompression: true,
  407. LocalSvrConf: LocalSvrConf{
  408. LocalIP: "114.114.114.114",
  409. LocalPort: 6011,
  410. },
  411. BandwidthLimitMode: BandwidthLimitModeClient,
  412. },
  413. RemotePort: 6011,
  414. },
  415. testUser + ".web01": &HTTPProxyConf{
  416. BaseProxyConf: BaseProxyConf{
  417. ProxyName: testUser + ".web01",
  418. ProxyType: consts.HTTPProxy,
  419. UseCompression: true,
  420. UseEncryption: true,
  421. LocalSvrConf: LocalSvrConf{
  422. LocalIP: "127.0.0.9",
  423. LocalPort: 89,
  424. },
  425. HealthCheckConf: HealthCheckConf{
  426. HealthCheckType: consts.HTTPProxy,
  427. HealthCheckTimeoutS: 3,
  428. HealthCheckMaxFailed: 3,
  429. HealthCheckIntervalS: 19,
  430. HealthCheckURL: "http://127.0.0.9:89/status",
  431. },
  432. BandwidthLimitMode: BandwidthLimitModeClient,
  433. },
  434. DomainConf: DomainConf{
  435. CustomDomains: []string{"web02.yourdomain.com"},
  436. SubDomain: "web01",
  437. },
  438. Locations: []string{"/", "/pic"},
  439. HTTPUser: "admin",
  440. HTTPPwd: "admin",
  441. HostHeaderRewrite: "example.com",
  442. Headers: map[string]string{
  443. "X-From-Where": "frp",
  444. },
  445. },
  446. testUser + ".web02": &HTTPSProxyConf{
  447. BaseProxyConf: BaseProxyConf{
  448. ProxyName: testUser + ".web02",
  449. ProxyType: consts.HTTPSProxy,
  450. UseCompression: true,
  451. UseEncryption: true,
  452. LocalSvrConf: LocalSvrConf{
  453. LocalIP: "127.0.0.9",
  454. LocalPort: 8009,
  455. },
  456. ProxyProtocolVersion: "v2",
  457. BandwidthLimitMode: BandwidthLimitModeClient,
  458. },
  459. DomainConf: DomainConf{
  460. CustomDomains: []string{"web02.yourdomain.com"},
  461. SubDomain: "web01",
  462. },
  463. },
  464. testUser + ".secret_tcp": &STCPProxyConf{
  465. BaseProxyConf: BaseProxyConf{
  466. ProxyName: testUser + ".secret_tcp",
  467. ProxyType: consts.STCPProxy,
  468. LocalSvrConf: LocalSvrConf{
  469. LocalIP: "127.0.0.1",
  470. LocalPort: 22,
  471. },
  472. BandwidthLimitMode: BandwidthLimitModeClient,
  473. },
  474. Role: "server",
  475. Sk: "abcdefg",
  476. },
  477. testUser + ".p2p_tcp": &XTCPProxyConf{
  478. BaseProxyConf: BaseProxyConf{
  479. ProxyName: testUser + ".p2p_tcp",
  480. ProxyType: consts.XTCPProxy,
  481. LocalSvrConf: LocalSvrConf{
  482. LocalIP: "127.0.0.1",
  483. LocalPort: 22,
  484. },
  485. BandwidthLimitMode: BandwidthLimitModeClient,
  486. },
  487. Role: "server",
  488. Sk: "abcdefg",
  489. },
  490. testUser + ".tcpmuxhttpconnect": &TCPMuxProxyConf{
  491. BaseProxyConf: BaseProxyConf{
  492. ProxyName: testUser + ".tcpmuxhttpconnect",
  493. ProxyType: consts.TCPMuxProxy,
  494. LocalSvrConf: LocalSvrConf{
  495. LocalIP: "127.0.0.1",
  496. LocalPort: 10701,
  497. },
  498. BandwidthLimitMode: BandwidthLimitModeClient,
  499. },
  500. DomainConf: DomainConf{
  501. CustomDomains: []string{"tunnel1"},
  502. SubDomain: "",
  503. },
  504. Multiplexer: "httpconnect",
  505. },
  506. testUser + ".plugin_unix_domain_socket": &TCPProxyConf{
  507. BaseProxyConf: BaseProxyConf{
  508. ProxyName: testUser + ".plugin_unix_domain_socket",
  509. ProxyType: consts.TCPProxy,
  510. LocalSvrConf: LocalSvrConf{
  511. LocalIP: "127.0.0.1",
  512. Plugin: "unix_domain_socket",
  513. PluginParams: map[string]string{
  514. "plugin_unix_path": "/var/run/docker.sock",
  515. },
  516. },
  517. BandwidthLimitMode: BandwidthLimitModeClient,
  518. },
  519. RemotePort: 6003,
  520. },
  521. testUser + ".plugin_http_proxy": &TCPProxyConf{
  522. BaseProxyConf: BaseProxyConf{
  523. ProxyName: testUser + ".plugin_http_proxy",
  524. ProxyType: consts.TCPProxy,
  525. LocalSvrConf: LocalSvrConf{
  526. LocalIP: "127.0.0.1",
  527. Plugin: "http_proxy",
  528. PluginParams: map[string]string{
  529. "plugin_http_user": "abc",
  530. "plugin_http_passwd": "abc",
  531. },
  532. },
  533. BandwidthLimitMode: BandwidthLimitModeClient,
  534. },
  535. RemotePort: 6004,
  536. },
  537. testUser + ".plugin_socks5": &TCPProxyConf{
  538. BaseProxyConf: BaseProxyConf{
  539. ProxyName: testUser + ".plugin_socks5",
  540. ProxyType: consts.TCPProxy,
  541. LocalSvrConf: LocalSvrConf{
  542. LocalIP: "127.0.0.1",
  543. Plugin: "socks5",
  544. PluginParams: map[string]string{
  545. "plugin_user": "abc",
  546. "plugin_passwd": "abc",
  547. },
  548. },
  549. BandwidthLimitMode: BandwidthLimitModeClient,
  550. },
  551. RemotePort: 6005,
  552. },
  553. testUser + ".plugin_static_file": &TCPProxyConf{
  554. BaseProxyConf: BaseProxyConf{
  555. ProxyName: testUser + ".plugin_static_file",
  556. ProxyType: consts.TCPProxy,
  557. LocalSvrConf: LocalSvrConf{
  558. LocalIP: "127.0.0.1",
  559. Plugin: "static_file",
  560. PluginParams: map[string]string{
  561. "plugin_local_path": "/var/www/blog",
  562. "plugin_strip_prefix": "static",
  563. "plugin_http_user": "abc",
  564. "plugin_http_passwd": "abc",
  565. },
  566. },
  567. BandwidthLimitMode: BandwidthLimitModeClient,
  568. },
  569. RemotePort: 6006,
  570. },
  571. testUser + ".plugin_https2http": &HTTPSProxyConf{
  572. BaseProxyConf: BaseProxyConf{
  573. ProxyName: testUser + ".plugin_https2http",
  574. ProxyType: consts.HTTPSProxy,
  575. LocalSvrConf: LocalSvrConf{
  576. LocalIP: "127.0.0.1",
  577. Plugin: "https2http",
  578. PluginParams: map[string]string{
  579. "plugin_local_addr": "127.0.0.1:80",
  580. "plugin_crt_path": "./server.crt",
  581. "plugin_key_path": "./server.key",
  582. "plugin_host_header_rewrite": "127.0.0.1",
  583. "plugin_header_X-From-Where": "frp",
  584. },
  585. },
  586. BandwidthLimitMode: BandwidthLimitModeClient,
  587. },
  588. DomainConf: DomainConf{
  589. CustomDomains: []string{"test.yourdomain.com"},
  590. },
  591. },
  592. testUser + ".plugin_http2https": &HTTPProxyConf{
  593. BaseProxyConf: BaseProxyConf{
  594. ProxyName: testUser + ".plugin_http2https",
  595. ProxyType: consts.HTTPProxy,
  596. LocalSvrConf: LocalSvrConf{
  597. LocalIP: "127.0.0.1",
  598. Plugin: "http2https",
  599. PluginParams: map[string]string{
  600. "plugin_local_addr": "127.0.0.1:443",
  601. "plugin_host_header_rewrite": "127.0.0.1",
  602. "plugin_header_X-From-Where": "frp",
  603. },
  604. },
  605. BandwidthLimitMode: BandwidthLimitModeClient,
  606. },
  607. DomainConf: DomainConf{
  608. CustomDomains: []string{"test.yourdomain.com"},
  609. },
  610. },
  611. }
  612. visitorExpected := map[string]VisitorConf{
  613. testUser + ".secret_tcp_visitor": &STCPVisitorConf{
  614. BaseVisitorConf: BaseVisitorConf{
  615. ProxyName: testUser + ".secret_tcp_visitor",
  616. ProxyType: consts.STCPProxy,
  617. Role: "visitor",
  618. Sk: "abcdefg",
  619. ServerName: testVisitorPrefix + "secret_tcp",
  620. BindAddr: "127.0.0.1",
  621. BindPort: 9000,
  622. },
  623. },
  624. testUser + ".p2p_tcp_visitor": &XTCPVisitorConf{
  625. BaseVisitorConf: BaseVisitorConf{
  626. ProxyName: testUser + ".p2p_tcp_visitor",
  627. ProxyType: consts.XTCPProxy,
  628. Role: "visitor",
  629. Sk: "abcdefg",
  630. ServerName: testProxyPrefix + "p2p_tcp",
  631. BindAddr: "127.0.0.1",
  632. BindPort: 9001,
  633. },
  634. Protocol: "quic",
  635. MaxRetriesAnHour: 8,
  636. MinRetryInterval: 90,
  637. },
  638. }
  639. proxyActual, visitorActual, err := LoadAllProxyConfsFromIni(testUser, testClientBytesWithFull, nil)
  640. assert.NoError(err)
  641. assert.Equal(proxyExpected, proxyActual)
  642. assert.Equal(visitorExpected, visitorActual)
  643. }