protocol.go 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 common
  20. const (
  21. TUNNEL_PROTOCOL_SSH = "SSH"
  22. TUNNEL_PROTOCOL_OBFUSCATED_SSH = "OSSH"
  23. TUNNEL_PROTOCOL_UNFRONTED_MEEK = "UNFRONTED-MEEK-OSSH"
  24. TUNNEL_PROTOCOL_UNFRONTED_MEEK_HTTPS = "UNFRONTED-MEEK-HTTPS-OSSH"
  25. TUNNEL_PROTOCOL_FRONTED_MEEK = "FRONTED-MEEK-OSSH"
  26. TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP = "FRONTED-MEEK-HTTP-OSSH"
  27. SERVER_ENTRY_SOURCE_EMBEDDED = "EMBEDDED"
  28. SERVER_ENTRY_SOURCE_REMOTE = "REMOTE"
  29. SERVER_ENTRY_SOURCE_DISCOVERY = "DISCOVERY"
  30. SERVER_ENTRY_SOURCE_TARGET = "TARGET"
  31. CAPABILITY_SSH_API_REQUESTS = "ssh-api-requests"
  32. CAPABILITY_UNTUNNELED_WEB_API_REQUESTS = "handshake"
  33. PSIPHON_API_HANDSHAKE_REQUEST_NAME = "psiphon-handshake"
  34. PSIPHON_API_CONNECTED_REQUEST_NAME = "psiphon-connected"
  35. PSIPHON_API_STATUS_REQUEST_NAME = "psiphon-status"
  36. PSIPHON_API_CLIENT_VERIFICATION_REQUEST_NAME = "psiphon-client-verification"
  37. PSIPHON_API_CLIENT_SESSION_ID_LENGTH = 16
  38. PSIPHON_SSH_API_PROTOCOL = "ssh"
  39. PSIPHON_WEB_API_PROTOCOL = "web"
  40. )
  41. var SupportedTunnelProtocols = []string{
  42. TUNNEL_PROTOCOL_FRONTED_MEEK,
  43. TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP,
  44. TUNNEL_PROTOCOL_UNFRONTED_MEEK,
  45. TUNNEL_PROTOCOL_UNFRONTED_MEEK_HTTPS,
  46. TUNNEL_PROTOCOL_OBFUSCATED_SSH,
  47. TUNNEL_PROTOCOL_SSH,
  48. }
  49. var SupportedServerEntrySources = []string{
  50. SERVER_ENTRY_SOURCE_EMBEDDED,
  51. SERVER_ENTRY_SOURCE_REMOTE,
  52. SERVER_ENTRY_SOURCE_DISCOVERY,
  53. SERVER_ENTRY_SOURCE_TARGET,
  54. }
  55. func TunnelProtocolUsesSSH(protocol string) bool {
  56. return true
  57. }
  58. func TunnelProtocolUsesObfuscatedSSH(protocol string) bool {
  59. return protocol != TUNNEL_PROTOCOL_SSH
  60. }
  61. func TunnelProtocolUsesMeekHTTP(protocol string) bool {
  62. return protocol == TUNNEL_PROTOCOL_UNFRONTED_MEEK ||
  63. protocol == TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP
  64. }
  65. func TunnelProtocolUsesMeekHTTPS(protocol string) bool {
  66. return protocol == TUNNEL_PROTOCOL_FRONTED_MEEK ||
  67. protocol == TUNNEL_PROTOCOL_UNFRONTED_MEEK_HTTPS
  68. }
  69. type HandshakeResponse struct {
  70. Homepages []string `json:"homepages"`
  71. UpgradeClientVersion string `json:"upgrade_client_version"`
  72. PageViewRegexes []map[string]string `json:"page_view_regexes"`
  73. HttpsRequestRegexes []map[string]string `json:"https_request_regexes"`
  74. EncodedServerList []string `json:"encoded_server_list"`
  75. ClientRegion string `json:"client_region"`
  76. ServerTimestamp string `json:"server_timestamp"`
  77. }
  78. type ConnectedResponse struct {
  79. ConnectedTimestamp string `json:"connected_timestamp"`
  80. }