项目作者: jamescun

项目描述 :
Run SSH and HTTP(S) on the same port
高级语言: Go
项目地址: git://github.com/jamescun/switcher.git
创建时间: 2015-01-20T21:37:36Z
项目社区:https://github.com/jamescun/switcher

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Switcher

Switcher

Switcher is a proxy server which accepts connections and proxies based on which protocol is detected.

Currently implemented is:

  • SSH

The use case is running HTTP(S) and SSH on the same port.

Usage

Download release or Build:

  1. make

To get help:

  1. $ ./switcher --help
  2. Switcher 1.0.0
  3. usage: switcher [options]
  4. Options:
  5. --listen <:80> Server Listen Address
  6. --ssh <127.0.0.1:22> SSH Server Address
  7. --default <127.0.0.1:8080> Default Server Address
  8. Examples:
  9. To serve SSH(127.0.0.1:22) and HTTP(127.0.0.1:8080) on port 80
  10. $ switcher
  11. To serve SSH(127.0.0.1:2222) and HTTPS(127.0.0.1:443) on port 443
  12. $ switcher --listen :443 --ssh 127.0.0.1:2222 --default 127.0.0.1:443

Example

Run switcher on HTTP port 80, proxy to SSH on 127.0.0.1:22 and Nginx on 127.0.0.1:8080

  1. $ switcher --listen :80 --ssh 127.0.0.1:22 --default 127.0.0.1:8080

To test HTTP:

  1. $ curl -I http://my-server.local
  2. HTTP/1.1 200 OK

To test SSH

  1. $ ssh james@my-server.local -p 80
  2. Password:

Why not sslh

Switcher is heavily influenced by sslh. It started out as a learning exercise to discover how sslh worked and attempt an implementation in Go.

The result is useful in its own right through use of Go’s interfaces for protocol matching (making adding new protocols trivial), and lightweight goroutines (instead of forking, which is more CPU intensive under load).

License

3-Clause “Modified” BSD Licence.

License