client_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  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. DisableCustomTLSFirstByte: true,
  266. DNSServer: "8.8.8.9",
  267. Start: []string{"ssh", "dns"},
  268. HeartbeatInterval: 39,
  269. HeartbeatTimeout: 99,
  270. Metas: map[string]string{
  271. "var1": "123",
  272. "var2": "234",
  273. },
  274. UDPPacketSize: 1509,
  275. IncludeConfigFiles: []string{},
  276. }
  277. common, err := UnmarshalClientConfFromIni(testClientBytesWithFull)
  278. assert.NoError(err)
  279. assert.EqualValues(expected, common)
  280. }
  281. func Test_LoadClientBasicConf(t *testing.T) {
  282. assert := assert.New(t)
  283. proxyExpected := map[string]ProxyConf{
  284. testUser + ".ssh": &TCPProxyConf{
  285. BaseProxyConf: BaseProxyConf{
  286. ProxyName: testUser + ".ssh",
  287. ProxyType: consts.TCPProxy,
  288. UseCompression: true,
  289. UseEncryption: true,
  290. Group: "test_group",
  291. GroupKey: "123456",
  292. BandwidthLimit: MustBandwidthQuantity("19MB"),
  293. BandwidthLimitMode: BandwidthLimitModeServer,
  294. Metas: map[string]string{
  295. "var1": "123",
  296. "var2": "234",
  297. },
  298. LocalSvrConf: LocalSvrConf{
  299. LocalIP: "127.0.0.9",
  300. LocalPort: 29,
  301. },
  302. HealthCheckConf: HealthCheckConf{
  303. HealthCheckType: consts.TCPProxy,
  304. HealthCheckTimeoutS: 3,
  305. HealthCheckMaxFailed: 3,
  306. HealthCheckIntervalS: 19,
  307. HealthCheckAddr: "127.0.0.9:29",
  308. },
  309. },
  310. RemotePort: 6009,
  311. },
  312. testUser + ".ssh_random": &TCPProxyConf{
  313. BaseProxyConf: BaseProxyConf{
  314. ProxyName: testUser + ".ssh_random",
  315. ProxyType: consts.TCPProxy,
  316. LocalSvrConf: LocalSvrConf{
  317. LocalIP: "127.0.0.9",
  318. LocalPort: 29,
  319. },
  320. BandwidthLimitMode: BandwidthLimitModeClient,
  321. },
  322. RemotePort: 9,
  323. },
  324. testUser + ".tcp_port_0": &TCPProxyConf{
  325. BaseProxyConf: BaseProxyConf{
  326. ProxyName: testUser + ".tcp_port_0",
  327. ProxyType: consts.TCPProxy,
  328. LocalSvrConf: LocalSvrConf{
  329. LocalIP: "127.0.0.9",
  330. LocalPort: 6010,
  331. },
  332. BandwidthLimitMode: BandwidthLimitModeClient,
  333. },
  334. RemotePort: 6010,
  335. },
  336. testUser + ".tcp_port_1": &TCPProxyConf{
  337. BaseProxyConf: BaseProxyConf{
  338. ProxyName: testUser + ".tcp_port_1",
  339. ProxyType: consts.TCPProxy,
  340. LocalSvrConf: LocalSvrConf{
  341. LocalIP: "127.0.0.9",
  342. LocalPort: 6011,
  343. },
  344. BandwidthLimitMode: BandwidthLimitModeClient,
  345. },
  346. RemotePort: 6011,
  347. },
  348. testUser + ".tcp_port_2": &TCPProxyConf{
  349. BaseProxyConf: BaseProxyConf{
  350. ProxyName: testUser + ".tcp_port_2",
  351. ProxyType: consts.TCPProxy,
  352. LocalSvrConf: LocalSvrConf{
  353. LocalIP: "127.0.0.9",
  354. LocalPort: 6019,
  355. },
  356. BandwidthLimitMode: BandwidthLimitModeClient,
  357. },
  358. RemotePort: 6019,
  359. },
  360. testUser + ".dns": &UDPProxyConf{
  361. BaseProxyConf: BaseProxyConf{
  362. ProxyName: testUser + ".dns",
  363. ProxyType: consts.UDPProxy,
  364. UseEncryption: true,
  365. UseCompression: true,
  366. LocalSvrConf: LocalSvrConf{
  367. LocalIP: "114.114.114.114",
  368. LocalPort: 59,
  369. },
  370. BandwidthLimitMode: BandwidthLimitModeClient,
  371. },
  372. RemotePort: 6009,
  373. },
  374. testUser + ".udp_port_0": &UDPProxyConf{
  375. BaseProxyConf: BaseProxyConf{
  376. ProxyName: testUser + ".udp_port_0",
  377. ProxyType: consts.UDPProxy,
  378. UseEncryption: true,
  379. UseCompression: true,
  380. LocalSvrConf: LocalSvrConf{
  381. LocalIP: "114.114.114.114",
  382. LocalPort: 6000,
  383. },
  384. BandwidthLimitMode: BandwidthLimitModeClient,
  385. },
  386. RemotePort: 6000,
  387. },
  388. testUser + ".udp_port_1": &UDPProxyConf{
  389. BaseProxyConf: BaseProxyConf{
  390. ProxyName: testUser + ".udp_port_1",
  391. ProxyType: consts.UDPProxy,
  392. UseEncryption: true,
  393. UseCompression: true,
  394. LocalSvrConf: LocalSvrConf{
  395. LocalIP: "114.114.114.114",
  396. LocalPort: 6010,
  397. },
  398. BandwidthLimitMode: BandwidthLimitModeClient,
  399. },
  400. RemotePort: 6010,
  401. },
  402. testUser + ".udp_port_2": &UDPProxyConf{
  403. BaseProxyConf: BaseProxyConf{
  404. ProxyName: testUser + ".udp_port_2",
  405. ProxyType: consts.UDPProxy,
  406. UseEncryption: true,
  407. UseCompression: true,
  408. LocalSvrConf: LocalSvrConf{
  409. LocalIP: "114.114.114.114",
  410. LocalPort: 6011,
  411. },
  412. BandwidthLimitMode: BandwidthLimitModeClient,
  413. },
  414. RemotePort: 6011,
  415. },
  416. testUser + ".web01": &HTTPProxyConf{
  417. BaseProxyConf: BaseProxyConf{
  418. ProxyName: testUser + ".web01",
  419. ProxyType: consts.HTTPProxy,
  420. UseCompression: true,
  421. UseEncryption: true,
  422. LocalSvrConf: LocalSvrConf{
  423. LocalIP: "127.0.0.9",
  424. LocalPort: 89,
  425. },
  426. HealthCheckConf: HealthCheckConf{
  427. HealthCheckType: consts.HTTPProxy,
  428. HealthCheckTimeoutS: 3,
  429. HealthCheckMaxFailed: 3,
  430. HealthCheckIntervalS: 19,
  431. HealthCheckURL: "http://127.0.0.9:89/status",
  432. },
  433. BandwidthLimitMode: BandwidthLimitModeClient,
  434. },
  435. DomainConf: DomainConf{
  436. CustomDomains: []string{"web02.yourdomain.com"},
  437. SubDomain: "web01",
  438. },
  439. Locations: []string{"/", "/pic"},
  440. HTTPUser: "admin",
  441. HTTPPwd: "admin",
  442. HostHeaderRewrite: "example.com",
  443. Headers: map[string]string{
  444. "X-From-Where": "frp",
  445. },
  446. },
  447. testUser + ".web02": &HTTPSProxyConf{
  448. BaseProxyConf: BaseProxyConf{
  449. ProxyName: testUser + ".web02",
  450. ProxyType: consts.HTTPSProxy,
  451. UseCompression: true,
  452. UseEncryption: true,
  453. LocalSvrConf: LocalSvrConf{
  454. LocalIP: "127.0.0.9",
  455. LocalPort: 8009,
  456. },
  457. ProxyProtocolVersion: "v2",
  458. BandwidthLimitMode: BandwidthLimitModeClient,
  459. },
  460. DomainConf: DomainConf{
  461. CustomDomains: []string{"web02.yourdomain.com"},
  462. SubDomain: "web01",
  463. },
  464. },
  465. testUser + ".secret_tcp": &STCPProxyConf{
  466. BaseProxyConf: BaseProxyConf{
  467. ProxyName: testUser + ".secret_tcp",
  468. ProxyType: consts.STCPProxy,
  469. LocalSvrConf: LocalSvrConf{
  470. LocalIP: "127.0.0.1",
  471. LocalPort: 22,
  472. },
  473. BandwidthLimitMode: BandwidthLimitModeClient,
  474. },
  475. RoleServerCommonConf: RoleServerCommonConf{
  476. Role: "server",
  477. Sk: "abcdefg",
  478. },
  479. },
  480. testUser + ".p2p_tcp": &XTCPProxyConf{
  481. BaseProxyConf: BaseProxyConf{
  482. ProxyName: testUser + ".p2p_tcp",
  483. ProxyType: consts.XTCPProxy,
  484. LocalSvrConf: LocalSvrConf{
  485. LocalIP: "127.0.0.1",
  486. LocalPort: 22,
  487. },
  488. BandwidthLimitMode: BandwidthLimitModeClient,
  489. },
  490. RoleServerCommonConf: RoleServerCommonConf{
  491. Role: "server",
  492. Sk: "abcdefg",
  493. },
  494. },
  495. testUser + ".tcpmuxhttpconnect": &TCPMuxProxyConf{
  496. BaseProxyConf: BaseProxyConf{
  497. ProxyName: testUser + ".tcpmuxhttpconnect",
  498. ProxyType: consts.TCPMuxProxy,
  499. LocalSvrConf: LocalSvrConf{
  500. LocalIP: "127.0.0.1",
  501. LocalPort: 10701,
  502. },
  503. BandwidthLimitMode: BandwidthLimitModeClient,
  504. },
  505. DomainConf: DomainConf{
  506. CustomDomains: []string{"tunnel1"},
  507. SubDomain: "",
  508. },
  509. Multiplexer: "httpconnect",
  510. },
  511. testUser + ".plugin_unix_domain_socket": &TCPProxyConf{
  512. BaseProxyConf: BaseProxyConf{
  513. ProxyName: testUser + ".plugin_unix_domain_socket",
  514. ProxyType: consts.TCPProxy,
  515. LocalSvrConf: LocalSvrConf{
  516. LocalIP: "127.0.0.1",
  517. Plugin: "unix_domain_socket",
  518. PluginParams: map[string]string{
  519. "plugin_unix_path": "/var/run/docker.sock",
  520. },
  521. },
  522. BandwidthLimitMode: BandwidthLimitModeClient,
  523. },
  524. RemotePort: 6003,
  525. },
  526. testUser + ".plugin_http_proxy": &TCPProxyConf{
  527. BaseProxyConf: BaseProxyConf{
  528. ProxyName: testUser + ".plugin_http_proxy",
  529. ProxyType: consts.TCPProxy,
  530. LocalSvrConf: LocalSvrConf{
  531. LocalIP: "127.0.0.1",
  532. Plugin: "http_proxy",
  533. PluginParams: map[string]string{
  534. "plugin_http_user": "abc",
  535. "plugin_http_passwd": "abc",
  536. },
  537. },
  538. BandwidthLimitMode: BandwidthLimitModeClient,
  539. },
  540. RemotePort: 6004,
  541. },
  542. testUser + ".plugin_socks5": &TCPProxyConf{
  543. BaseProxyConf: BaseProxyConf{
  544. ProxyName: testUser + ".plugin_socks5",
  545. ProxyType: consts.TCPProxy,
  546. LocalSvrConf: LocalSvrConf{
  547. LocalIP: "127.0.0.1",
  548. Plugin: "socks5",
  549. PluginParams: map[string]string{
  550. "plugin_user": "abc",
  551. "plugin_passwd": "abc",
  552. },
  553. },
  554. BandwidthLimitMode: BandwidthLimitModeClient,
  555. },
  556. RemotePort: 6005,
  557. },
  558. testUser + ".plugin_static_file": &TCPProxyConf{
  559. BaseProxyConf: BaseProxyConf{
  560. ProxyName: testUser + ".plugin_static_file",
  561. ProxyType: consts.TCPProxy,
  562. LocalSvrConf: LocalSvrConf{
  563. LocalIP: "127.0.0.1",
  564. Plugin: "static_file",
  565. PluginParams: map[string]string{
  566. "plugin_local_path": "/var/www/blog",
  567. "plugin_strip_prefix": "static",
  568. "plugin_http_user": "abc",
  569. "plugin_http_passwd": "abc",
  570. },
  571. },
  572. BandwidthLimitMode: BandwidthLimitModeClient,
  573. },
  574. RemotePort: 6006,
  575. },
  576. testUser + ".plugin_https2http": &HTTPSProxyConf{
  577. BaseProxyConf: BaseProxyConf{
  578. ProxyName: testUser + ".plugin_https2http",
  579. ProxyType: consts.HTTPSProxy,
  580. LocalSvrConf: LocalSvrConf{
  581. LocalIP: "127.0.0.1",
  582. Plugin: "https2http",
  583. PluginParams: map[string]string{
  584. "plugin_local_addr": "127.0.0.1:80",
  585. "plugin_crt_path": "./server.crt",
  586. "plugin_key_path": "./server.key",
  587. "plugin_host_header_rewrite": "127.0.0.1",
  588. "plugin_header_X-From-Where": "frp",
  589. },
  590. },
  591. BandwidthLimitMode: BandwidthLimitModeClient,
  592. },
  593. DomainConf: DomainConf{
  594. CustomDomains: []string{"test.yourdomain.com"},
  595. },
  596. },
  597. testUser + ".plugin_http2https": &HTTPProxyConf{
  598. BaseProxyConf: BaseProxyConf{
  599. ProxyName: testUser + ".plugin_http2https",
  600. ProxyType: consts.HTTPProxy,
  601. LocalSvrConf: LocalSvrConf{
  602. LocalIP: "127.0.0.1",
  603. Plugin: "http2https",
  604. PluginParams: map[string]string{
  605. "plugin_local_addr": "127.0.0.1:443",
  606. "plugin_host_header_rewrite": "127.0.0.1",
  607. "plugin_header_X-From-Where": "frp",
  608. },
  609. },
  610. BandwidthLimitMode: BandwidthLimitModeClient,
  611. },
  612. DomainConf: DomainConf{
  613. CustomDomains: []string{"test.yourdomain.com"},
  614. },
  615. },
  616. }
  617. visitorExpected := map[string]VisitorConf{
  618. testUser + ".secret_tcp_visitor": &STCPVisitorConf{
  619. BaseVisitorConf: BaseVisitorConf{
  620. ProxyName: testUser + ".secret_tcp_visitor",
  621. ProxyType: consts.STCPProxy,
  622. Role: "visitor",
  623. Sk: "abcdefg",
  624. ServerName: testVisitorPrefix + "secret_tcp",
  625. BindAddr: "127.0.0.1",
  626. BindPort: 9000,
  627. },
  628. },
  629. testUser + ".p2p_tcp_visitor": &XTCPVisitorConf{
  630. BaseVisitorConf: BaseVisitorConf{
  631. ProxyName: testUser + ".p2p_tcp_visitor",
  632. ProxyType: consts.XTCPProxy,
  633. Role: "visitor",
  634. Sk: "abcdefg",
  635. ServerName: testProxyPrefix + "p2p_tcp",
  636. BindAddr: "127.0.0.1",
  637. BindPort: 9001,
  638. },
  639. Protocol: "quic",
  640. MaxRetriesAnHour: 8,
  641. MinRetryInterval: 90,
  642. FallbackTimeoutMs: 1000,
  643. },
  644. }
  645. proxyActual, visitorActual, err := LoadAllProxyConfsFromIni(testUser, testClientBytesWithFull, nil)
  646. assert.NoError(err)
  647. assert.Equal(proxyExpected, proxyActual)
  648. assert.Equal(visitorExpected, visitorActual)
  649. }