feat: implement VPN platform management and real protocol services
This commit is contained in:
commit
58c036c34c
45 files changed
+9244
No files matched your search
@@ -0,0 +1,37 @@
|
||||
package frp
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidateMultipleHTTPAndTCPProxies(t *testing.T) {
|
||||
s := New()
|
||||
cfg, err := s.Validate(map[string]interface{}{
|
||||
"mode": "client",
|
||||
"server_addr": "frps.example.com",
|
||||
"proxies": []interface{}{
|
||||
map[string]interface{}{"name": "ssh", "type": "tcp", "local_port": float64(22), "remote_port": float64(2222)},
|
||||
map[string]interface{}{"name": "web", "type": "https", "local_port": float64(443), "custom_domains": []interface{}{"vpn.example.com"}},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
text := s.frpcConfig(cfg, "test-token")
|
||||
for _, expected := range []string{"name = \"ssh\"", "remotePort = 2222", "name = \"web\"", "customDomains = [\"vpn.example.com\"]"} {
|
||||
if !strings.Contains(text, expected) {
|
||||
t.Errorf("generated config missing %q:\n%s", expected, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPProxyNeedsDomain(t *testing.T) {
|
||||
_, err := New().Validate(map[string]interface{}{
|
||||
"mode": "client", "server_addr": "127.0.0.1",
|
||||
"proxies": []interface{}{map[string]interface{}{"name": "web", "type": "http", "local_port": float64(8080)}},
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected HTTP domain validation error")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user