config.go 20 KB

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