config.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /*
  2. * Copyright (c) 2016, Psiphon Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. package server
  20. import (
  21. "crypto/rand"
  22. "crypto/rsa"
  23. "crypto/x509"
  24. "encoding/base64"
  25. "encoding/json"
  26. "encoding/pem"
  27. "errors"
  28. "fmt"
  29. "net"
  30. "strconv"
  31. "strings"
  32. "time"
  33. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon"
  34. "golang.org/x/crypto/nacl/box"
  35. "golang.org/x/crypto/ssh"
  36. )
  37. const (
  38. SERVER_CONFIG_FILENAME = "psiphond.config"
  39. SERVER_TRAFFIC_RULES_FILENAME = "psiphond-traffic-rules.config"
  40. SERVER_ENTRY_FILENAME = "server-entry.dat"
  41. DEFAULT_SERVER_IP_ADDRESS = "127.0.0.1"
  42. WEB_SERVER_SECRET_BYTE_LENGTH = 32
  43. DISCOVERY_VALUE_KEY_BYTE_LENGTH = 32
  44. WEB_SERVER_READ_TIMEOUT = 10 * time.Second
  45. WEB_SERVER_WRITE_TIMEOUT = 10 * time.Second
  46. SSH_USERNAME_SUFFIX_BYTE_LENGTH = 8
  47. SSH_PASSWORD_BYTE_LENGTH = 32
  48. SSH_RSA_HOST_KEY_BITS = 2048
  49. SSH_HANDSHAKE_TIMEOUT = 30 * time.Second
  50. SSH_CONNECTION_READ_DEADLINE = 5 * time.Minute
  51. SSH_TCP_PORT_FORWARD_DIAL_TIMEOUT = 30 * time.Second
  52. SSH_TCP_PORT_FORWARD_COPY_BUFFER_SIZE = 8192
  53. SSH_OBFUSCATED_KEY_BYTE_LENGTH = 32
  54. GEOIP_SESSION_CACHE_TTL = 60 * time.Minute
  55. )
  56. // Config specifies the configuration and behavior of a Psiphon
  57. // server.
  58. type Config struct {
  59. // LogLevel specifies the log level. Valid values are:
  60. // panic, fatal, error, warn, info, debug
  61. LogLevel string
  62. // SyslogFacility specifies the syslog facility to log to.
  63. // When set, the local syslog service is used for message
  64. // logging.
  65. // Valid values include: "user", "local0", "local1", etc.
  66. SyslogFacility string
  67. // SyslogTag specifies an optional tag for syslog log
  68. // messages. The default tag is "psiphon-server". The
  69. // fail2ban logs, if enabled, also use this tag.
  70. SyslogTag string
  71. // Fail2BanFormat is a string format specifier for the
  72. // log message format to use for fail2ban integration for
  73. // blocking abusive clients by source IP address.
  74. // When set, logs with this format are made if clients fail
  75. // to authenticate.
  76. // The client's IP address is included with the log message.
  77. // An example format specifier, which should be compatible
  78. // with default SSH fail2ban configuration, is
  79. // "Authentication failure for psiphon-client from %s".
  80. Fail2BanFormat string
  81. // DiscoveryValueHMACKey is the network-wide secret value
  82. // used to determine a unique discovery strategy.
  83. DiscoveryValueHMACKey string
  84. // GeoIPDatabaseFilename is the path of the GeoIP2/GeoLite2
  85. // MaxMind database file. when blank, no GeoIP lookups are
  86. // performed.
  87. GeoIPDatabaseFilename string
  88. // PsinetDatabaseFilename is the path of the Psiphon automation
  89. // jsonpickle format Psiphon API data file.
  90. PsinetDatabaseFilename string
  91. // HostID is the ID of the server host; this is used for API
  92. // event logging.
  93. HostID string
  94. // ServerIPAddress is the public IP address of the server.
  95. ServerIPAddress string
  96. // WebServerPort is the listening port of the web server.
  97. // When <= 0, no web server component is run.
  98. WebServerPort int
  99. // WebServerSecret is the unique secret value that the client
  100. // must supply to make requests to the web server.
  101. WebServerSecret string
  102. // WebServerCertificate is the certificate the client uses to
  103. // authenticate the web server.
  104. WebServerCertificate string
  105. // WebServerPrivateKey is the private key the web server uses to
  106. // authenticate itself to clients.
  107. WebServerPrivateKey string
  108. // TunnelProtocolPorts specifies which tunnel protocols to run
  109. // and which ports to listen on for each protocol. Valid tunnel
  110. // protocols include: "SSH", "OSSH", "UNFRONTED-MEEK-OSSH",
  111. // "UNFRONTED-MEEK-HTTPS-OSSH", "FRONTED-MEEK-OSSH",
  112. // "FRONTED-MEEK-HTTP-OSSH".
  113. TunnelProtocolPorts map[string]int
  114. // SSHPrivateKey is the SSH host key. The same key is used for
  115. // all protocols, run by this server instance, which use SSH.
  116. SSHPrivateKey string
  117. // SSHServerVersion is the server version presented in the
  118. // identification string. The same value is used for all
  119. // protocols, run by this server instance, which use SSH.
  120. SSHServerVersion string
  121. // SSHUserName is the SSH user name to be presented by the
  122. // the tunnel-core client. The same value is used for all
  123. // protocols, run by this server instance, which use SSH.
  124. SSHUserName string
  125. // SSHPassword is the SSH password to be presented by the
  126. // the tunnel-core client. The same value is used for all
  127. // protocols, run by this server instance, which use SSH.
  128. SSHPassword string
  129. // ObfuscatedSSHKey is the secret key for use in the Obfuscated
  130. // SSH protocol. The same secret key is used for all protocols,
  131. // run by this server instance, which use Obfuscated SSH.
  132. ObfuscatedSSHKey string
  133. // MeekCookieEncryptionPrivateKey is the NaCl private key used
  134. // to decrypt meek cookie payload sent from clients. The same
  135. // key is used for all meek protocols run by this server instance.
  136. MeekCookieEncryptionPrivateKey string
  137. // MeekObfuscatedKey is the secret key used for obfuscating
  138. // meek cookies sent from clients. The same key is used for all
  139. // meek protocols run by this server instance.
  140. MeekObfuscatedKey string
  141. // MeekCertificateCommonName is the value used for the hostname
  142. // in the self-signed certificate generated and used for meek
  143. // HTTPS modes. The same value is used for all HTTPS meek
  144. // protocols.
  145. MeekCertificateCommonName string
  146. // MeekProhibitedHeaders is a list of HTTP headers to check for
  147. // in client requests. If one of these headers is found, the
  148. // request fails. This is used to defend against abuse.
  149. MeekProhibitedHeaders []string
  150. // MeekProxyForwardedForHeaders is a list of HTTP headers which
  151. // may be added by downstream HTTP proxies or CDNs in front
  152. // of clients. These headers supply the original client IP
  153. // address, which is geolocated for stats purposes. Headers
  154. // include, for example, X-Forwarded-For. The header's value
  155. // is assumed to be a comma delimted list of IP addresses where
  156. // the client IP is the first IP address in the list. Meek protocols
  157. // look for these headers and use the client IP address from
  158. // the header if any one is present and the value is a valid
  159. // IP address; otherwise the direct connection remote address is
  160. // used as the client IP.
  161. MeekProxyForwardedForHeaders []string
  162. // UDPInterceptUdpgwServerAddress specifies the network address of
  163. // a udpgw server which clients may be port forwarding to. When
  164. // specified, these TCP port forwards are intercepted and handled
  165. // directly by this server, which parses the SSH channel using the
  166. // udpgw protocol.
  167. UDPInterceptUdpgwServerAddress string
  168. // DNSServerAddress specifies the network address of a DNS server
  169. // to which DNS UDP packets will be forwarded to. When set, any
  170. // tunneled DNS UDP packets will be re-routed to this destination.
  171. UDPForwardDNSServerAddress string
  172. // LoadMonitorPeriodSeconds indicates how frequently to log server
  173. // load information (number of connected clients per tunnel protocol,
  174. // number of running goroutines, amount of memory allocated, etc.)
  175. // The default, 0, disables load logging.
  176. LoadMonitorPeriodSeconds int
  177. // TrafficRulesFilename is the path of a file containing a
  178. // JSON-encoded TrafficRulesSet, the traffic rules to apply to
  179. // Psiphon client tunnels.
  180. TrafficRulesFilename string
  181. }
  182. // RunWebServer indicates whether to run a web server component.
  183. func (config *Config) RunWebServer() bool {
  184. return config.WebServerPort > 0
  185. }
  186. // RunLoadMonitor indicates whether to monitor and log server load.
  187. func (config *Config) RunLoadMonitor() bool {
  188. return config.LoadMonitorPeriodSeconds > 0
  189. }
  190. // UseFail2Ban indicates whether to log client IP addresses, in authentication
  191. // failure cases, to the local syslog service AUTH facility for use by fail2ban.
  192. func (config *Config) UseFail2Ban() bool {
  193. return config.Fail2BanFormat != ""
  194. }
  195. // LoadConfig loads and validates a JSON encoded server config.
  196. func LoadConfig(configJSON []byte) (*Config, error) {
  197. var config Config
  198. err := json.Unmarshal(configJSON, &config)
  199. if err != nil {
  200. return nil, psiphon.ContextError(err)
  201. }
  202. if config.Fail2BanFormat != "" && strings.Count(config.Fail2BanFormat, "%s") != 1 {
  203. return nil, errors.New("Fail2BanFormat must have one '%%s' placeholder")
  204. }
  205. if config.ServerIPAddress == "" {
  206. return nil, errors.New("ServerIPAddress is missing from config file")
  207. }
  208. if config.WebServerPort > 0 && (config.WebServerSecret == "" || config.WebServerCertificate == "" ||
  209. config.WebServerPrivateKey == "") {
  210. return nil, errors.New(
  211. "Web server requires WebServerSecret, WebServerCertificate, WebServerPrivateKey")
  212. }
  213. for tunnelProtocol, _ := range config.TunnelProtocolPorts {
  214. if psiphon.TunnelProtocolUsesSSH(tunnelProtocol) ||
  215. psiphon.TunnelProtocolUsesObfuscatedSSH(tunnelProtocol) {
  216. if config.SSHPrivateKey == "" || config.SSHServerVersion == "" ||
  217. config.SSHUserName == "" || config.SSHPassword == "" {
  218. return nil, fmt.Errorf(
  219. "Tunnel protocol %s requires SSHPrivateKey, SSHServerVersion, SSHUserName, SSHPassword",
  220. tunnelProtocol)
  221. }
  222. }
  223. if psiphon.TunnelProtocolUsesObfuscatedSSH(tunnelProtocol) {
  224. if config.ObfuscatedSSHKey == "" {
  225. return nil, fmt.Errorf(
  226. "Tunnel protocol %s requires ObfuscatedSSHKey",
  227. tunnelProtocol)
  228. }
  229. }
  230. if psiphon.TunnelProtocolUsesMeekHTTP(tunnelProtocol) ||
  231. psiphon.TunnelProtocolUsesMeekHTTPS(tunnelProtocol) {
  232. if config.MeekCookieEncryptionPrivateKey == "" || config.MeekObfuscatedKey == "" {
  233. return nil, fmt.Errorf(
  234. "Tunnel protocol %s requires MeekCookieEncryptionPrivateKey, MeekObfuscatedKey",
  235. tunnelProtocol)
  236. }
  237. }
  238. if psiphon.TunnelProtocolUsesMeekHTTPS(tunnelProtocol) {
  239. if config.MeekCertificateCommonName == "" {
  240. return nil, fmt.Errorf(
  241. "Tunnel protocol %s requires MeekCertificateCommonName",
  242. tunnelProtocol)
  243. }
  244. }
  245. }
  246. validateNetworkAddress := func(address string) error {
  247. host, port, err := net.SplitHostPort(address)
  248. if err == nil && net.ParseIP(host) == nil {
  249. err = errors.New("Host must be an IP address")
  250. }
  251. if err == nil {
  252. _, err = strconv.Atoi(port)
  253. }
  254. return err
  255. }
  256. if config.UDPForwardDNSServerAddress != "" {
  257. if err := validateNetworkAddress(config.UDPForwardDNSServerAddress); err != nil {
  258. return nil, fmt.Errorf("UDPForwardDNSServerAddress is invalid: %s", err)
  259. }
  260. }
  261. if config.UDPInterceptUdpgwServerAddress != "" {
  262. if err := validateNetworkAddress(config.UDPInterceptUdpgwServerAddress); err != nil {
  263. return nil, fmt.Errorf("UDPInterceptUdpgwServerAddress is invalid: %s", err)
  264. }
  265. }
  266. return &config, nil
  267. }
  268. // GenerateConfigParams specifies customizations to be applied to
  269. // a generated server config.
  270. type GenerateConfigParams struct {
  271. ServerIPAddress string
  272. WebServerPort int
  273. EnableSSHAPIRequests bool
  274. TunnelProtocolPorts map[string]int
  275. TrafficRulesFilename string
  276. }
  277. // GenerateConfig creates a new Psiphon server config. It returns JSON
  278. // encoded configs and a client-compatible "server entry" for the server. It
  279. // generates all necessary secrets and key material, which are emitted in
  280. // the config file and server entry as necessary.
  281. // GenerateConfig uses sample values for many fields. The intention is for
  282. // generated configs to be used for testing or as a template for production
  283. // setup, not to generate production-ready configurations.
  284. func GenerateConfig(params *GenerateConfigParams) ([]byte, []byte, []byte, error) {
  285. // Input validation
  286. if net.ParseIP(params.ServerIPAddress) == nil {
  287. return nil, nil, nil, psiphon.ContextError(errors.New("invalid IP address"))
  288. }
  289. if len(params.TunnelProtocolPorts) == 0 {
  290. return nil, nil, nil, psiphon.ContextError(errors.New("no tunnel protocols"))
  291. }
  292. usedPort := make(map[int]bool)
  293. if params.WebServerPort != 0 {
  294. usedPort[params.WebServerPort] = true
  295. }
  296. usingMeek := false
  297. for protocol, port := range params.TunnelProtocolPorts {
  298. if !psiphon.Contains(psiphon.SupportedTunnelProtocols, protocol) {
  299. return nil, nil, nil, psiphon.ContextError(errors.New("invalid tunnel protocol"))
  300. }
  301. if usedPort[port] {
  302. return nil, nil, nil, psiphon.ContextError(errors.New("duplicate listening port"))
  303. }
  304. usedPort[port] = true
  305. if psiphon.TunnelProtocolUsesMeekHTTP(protocol) ||
  306. psiphon.TunnelProtocolUsesMeekHTTPS(protocol) {
  307. usingMeek = true
  308. }
  309. }
  310. // Web server config
  311. var webServerSecret, webServerCertificate, webServerPrivateKey string
  312. if params.WebServerPort != 0 {
  313. var err error
  314. webServerSecret, err = psiphon.MakeRandomStringHex(WEB_SERVER_SECRET_BYTE_LENGTH)
  315. if err != nil {
  316. return nil, nil, nil, psiphon.ContextError(err)
  317. }
  318. webServerCertificate, webServerPrivateKey, err = GenerateWebServerCertificate("")
  319. if err != nil {
  320. return nil, nil, nil, psiphon.ContextError(err)
  321. }
  322. }
  323. // SSH config
  324. // TODO: use other key types: anti-fingerprint by varying params
  325. rsaKey, err := rsa.GenerateKey(rand.Reader, SSH_RSA_HOST_KEY_BITS)
  326. if err != nil {
  327. return nil, nil, nil, psiphon.ContextError(err)
  328. }
  329. sshPrivateKey := pem.EncodeToMemory(
  330. &pem.Block{
  331. Type: "RSA PRIVATE KEY",
  332. Bytes: x509.MarshalPKCS1PrivateKey(rsaKey),
  333. },
  334. )
  335. signer, err := ssh.NewSignerFromKey(rsaKey)
  336. if err != nil {
  337. return nil, nil, nil, psiphon.ContextError(err)
  338. }
  339. sshPublicKey := signer.PublicKey()
  340. sshUserNameSuffix, err := psiphon.MakeRandomStringHex(SSH_USERNAME_SUFFIX_BYTE_LENGTH)
  341. if err != nil {
  342. return nil, nil, nil, psiphon.ContextError(err)
  343. }
  344. sshUserName := "psiphon_" + sshUserNameSuffix
  345. sshPassword, err := psiphon.MakeRandomStringHex(SSH_PASSWORD_BYTE_LENGTH)
  346. if err != nil {
  347. return nil, nil, nil, psiphon.ContextError(err)
  348. }
  349. // TODO: vary version string for anti-fingerprint
  350. sshServerVersion := "SSH-2.0-Psiphon"
  351. // Obfuscated SSH config
  352. obfuscatedSSHKey, err := psiphon.MakeRandomStringHex(SSH_OBFUSCATED_KEY_BYTE_LENGTH)
  353. if err != nil {
  354. return nil, nil, nil, psiphon.ContextError(err)
  355. }
  356. // Meek config
  357. var meekCookieEncryptionPublicKey, meekCookieEncryptionPrivateKey, meekObfuscatedKey string
  358. if usingMeek {
  359. rawMeekCookieEncryptionPublicKey, rawMeekCookieEncryptionPrivateKey, err :=
  360. box.GenerateKey(rand.Reader)
  361. if err != nil {
  362. return nil, nil, nil, psiphon.ContextError(err)
  363. }
  364. meekCookieEncryptionPublicKey = base64.StdEncoding.EncodeToString(rawMeekCookieEncryptionPublicKey[:])
  365. meekCookieEncryptionPrivateKey = base64.StdEncoding.EncodeToString(rawMeekCookieEncryptionPrivateKey[:])
  366. meekObfuscatedKey, err = psiphon.MakeRandomStringHex(SSH_OBFUSCATED_KEY_BYTE_LENGTH)
  367. if err != nil {
  368. return nil, nil, nil, psiphon.ContextError(err)
  369. }
  370. }
  371. // Other config
  372. discoveryValueHMACKey, err := psiphon.MakeRandomStringBase64(DISCOVERY_VALUE_KEY_BYTE_LENGTH)
  373. if err != nil {
  374. return nil, nil, nil, psiphon.ContextError(err)
  375. }
  376. // Assemble configs and server entry
  377. // Note: this config is intended for either testing or as an illustrative
  378. // example or template and is not intended for production deployment.
  379. config := &Config{
  380. LogLevel: "info",
  381. SyslogFacility: "user",
  382. SyslogTag: "psiphon-server",
  383. Fail2BanFormat: "Authentication failure for psiphon-client from %s",
  384. GeoIPDatabaseFilename: "",
  385. HostID: "example-host-id",
  386. ServerIPAddress: params.ServerIPAddress,
  387. DiscoveryValueHMACKey: discoveryValueHMACKey,
  388. WebServerPort: params.WebServerPort,
  389. WebServerSecret: webServerSecret,
  390. WebServerCertificate: webServerCertificate,
  391. WebServerPrivateKey: webServerPrivateKey,
  392. SSHPrivateKey: string(sshPrivateKey),
  393. SSHServerVersion: sshServerVersion,
  394. SSHUserName: sshUserName,
  395. SSHPassword: sshPassword,
  396. ObfuscatedSSHKey: obfuscatedSSHKey,
  397. TunnelProtocolPorts: params.TunnelProtocolPorts,
  398. UDPForwardDNSServerAddress: "8.8.8.8:53",
  399. UDPInterceptUdpgwServerAddress: "127.0.0.1:7300",
  400. MeekCookieEncryptionPrivateKey: meekCookieEncryptionPrivateKey,
  401. MeekObfuscatedKey: meekObfuscatedKey,
  402. MeekCertificateCommonName: "www.example.org",
  403. MeekProhibitedHeaders: nil,
  404. MeekProxyForwardedForHeaders: []string{"X-Forwarded-For"},
  405. LoadMonitorPeriodSeconds: 300,
  406. TrafficRulesFilename: params.TrafficRulesFilename,
  407. }
  408. encodedConfig, err := json.MarshalIndent(config, "\n", " ")
  409. if err != nil {
  410. return nil, nil, nil, psiphon.ContextError(err)
  411. }
  412. trafficRulesSet := &TrafficRulesSet{
  413. DefaultRules: TrafficRules{
  414. DefaultLimits: RateLimits{
  415. DownstreamUnlimitedBytes: 0,
  416. DownstreamBytesPerSecond: 0,
  417. UpstreamUnlimitedBytes: 0,
  418. UpstreamBytesPerSecond: 0,
  419. },
  420. IdleTCPPortForwardTimeoutMilliseconds: 30000,
  421. IdleUDPPortForwardTimeoutMilliseconds: 30000,
  422. MaxTCPPortForwardCount: 1024,
  423. MaxUDPPortForwardCount: 32,
  424. AllowTCPPorts: nil,
  425. AllowUDPPorts: nil,
  426. DenyTCPPorts: nil,
  427. DenyUDPPorts: nil,
  428. },
  429. }
  430. encodedTrafficRulesSet, err := json.MarshalIndent(trafficRulesSet, "\n", " ")
  431. if err != nil {
  432. return nil, nil, nil, psiphon.ContextError(err)
  433. }
  434. capabilities := []string{}
  435. if params.EnableSSHAPIRequests {
  436. capabilities = append(capabilities, psiphon.CAPABILITY_SSH_API_REQUESTS)
  437. }
  438. if params.WebServerPort != 0 {
  439. capabilities = append(capabilities, psiphon.CAPABILITY_UNTUNNELED_WEB_API_REQUESTS)
  440. }
  441. for protocol, _ := range params.TunnelProtocolPorts {
  442. capabilities = append(capabilities, psiphon.GetCapability(protocol))
  443. }
  444. sshPort := params.TunnelProtocolPorts["SSH"]
  445. obfuscatedSSHPort := params.TunnelProtocolPorts["OSSH"]
  446. // Meek port limitations
  447. // - fronted meek protocols are hard-wired in the client to be port 443 or 80.
  448. // - only one other meek port may be specified.
  449. meekPort := params.TunnelProtocolPorts["UNFRONTED-MEEK-OSSH"]
  450. if meekPort == 0 {
  451. meekPort = params.TunnelProtocolPorts["UNFRONTED-MEEK-HTTPS-OSSH"]
  452. }
  453. // Note: fronting params are a stub; this server entry will exercise
  454. // client and server fronting code paths, but not actually traverse
  455. // a fronting hop.
  456. serverEntryWebServerPort := ""
  457. strippedWebServerCertificate := ""
  458. if params.WebServerPort != 0 {
  459. serverEntryWebServerPort = fmt.Sprintf("%d", params.WebServerPort)
  460. // Server entry format omits the BEGIN/END lines and newlines
  461. lines := strings.Split(webServerCertificate, "\n")
  462. strippedWebServerCertificate = strings.Join(lines[1:len(lines)-2], "")
  463. }
  464. serverEntry := &psiphon.ServerEntry{
  465. IpAddress: params.ServerIPAddress,
  466. WebServerPort: serverEntryWebServerPort,
  467. WebServerSecret: webServerSecret,
  468. WebServerCertificate: strippedWebServerCertificate,
  469. SshPort: sshPort,
  470. SshUsername: sshUserName,
  471. SshPassword: sshPassword,
  472. SshHostKey: base64.RawStdEncoding.EncodeToString(sshPublicKey.Marshal()),
  473. SshObfuscatedPort: obfuscatedSSHPort,
  474. SshObfuscatedKey: obfuscatedSSHKey,
  475. Capabilities: capabilities,
  476. Region: "US",
  477. MeekServerPort: meekPort,
  478. MeekCookieEncryptionPublicKey: meekCookieEncryptionPublicKey,
  479. MeekObfuscatedKey: meekObfuscatedKey,
  480. MeekFrontingHosts: []string{params.ServerIPAddress},
  481. MeekFrontingAddresses: []string{params.ServerIPAddress},
  482. MeekFrontingDisableSNI: false,
  483. }
  484. encodedServerEntry, err := psiphon.EncodeServerEntry(serverEntry)
  485. if err != nil {
  486. return nil, nil, nil, psiphon.ContextError(err)
  487. }
  488. return encodedConfig, encodedTrafficRulesSet, []byte(encodedServerEntry), nil
  489. }