protocol.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. )
  39. var SupportedTunnelProtocols = []string{
  40. TUNNEL_PROTOCOL_FRONTED_MEEK,
  41. TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP,
  42. TUNNEL_PROTOCOL_UNFRONTED_MEEK,
  43. TUNNEL_PROTOCOL_UNFRONTED_MEEK_HTTPS,
  44. TUNNEL_PROTOCOL_OBFUSCATED_SSH,
  45. TUNNEL_PROTOCOL_SSH,
  46. }
  47. var SupportedServerEntrySources = []string{
  48. SERVER_ENTRY_SOURCE_EMBEDDED,
  49. SERVER_ENTRY_SOURCE_REMOTE,
  50. SERVER_ENTRY_SOURCE_DISCOVERY,
  51. SERVER_ENTRY_SOURCE_TARGET,
  52. }
  53. func TunnelProtocolUsesSSH(protocol string) bool {
  54. return true
  55. }
  56. func TunnelProtocolUsesObfuscatedSSH(protocol string) bool {
  57. return protocol != TUNNEL_PROTOCOL_SSH
  58. }
  59. func TunnelProtocolUsesMeekHTTP(protocol string) bool {
  60. return protocol == TUNNEL_PROTOCOL_UNFRONTED_MEEK ||
  61. protocol == TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP
  62. }
  63. func TunnelProtocolUsesMeekHTTPS(protocol string) bool {
  64. return protocol == TUNNEL_PROTOCOL_FRONTED_MEEK ||
  65. protocol == TUNNEL_PROTOCOL_UNFRONTED_MEEK_HTTPS
  66. }