Giter Site home page Giter Site logo

websocket-gateway's Introduction

websocket gateway

A gateway that translates websocket connections to tcp connections transparently.

build

gem install thor
thor cli:build

usage

Clients that setup a connection to gate on path /gate/{target:[a-zA-Z0-9.-_:]+}, will be proxied to backend tcp server specified by ${target} in configuration.

For example, if configuration is:

// supports comment line starting with '//'
{
  // __default__ is a special configuration that all other configuration will inherit from it
  // if some field is missing in other configuration, field in __default__ will be used.
  "__default__" : {
    "ssl": false
  },
  "api.example.com" : {
    "ip": "192.168.0.100",
    // only these ports will be proxied
    "port": "80,443,1024-30000",
    // whether connect backend server via ssl
    "ssl": true
  }
}

A client that connects to /gate/api.example.com:80 via websocket protocol, will be proxied to 192.168.0.100:80 and the data received from websocket will be transfered via tcp protocol to backend.

And if client is flashplayer, it may request for a policy file, this gateway can return a policy file to make flashplayer happy. This policy file is also configurable.

Usage of ./bin/wsgate (version 1.0.2):
  -addr string
    	Service Address (default "127.0.0.1:8080")
  -connect-target-timeout duration
    	maxium timeout connecting to game (default 2s)
  -fetch-interval duration
    	Server list fetch interval (default 30s)
  -help
    	print help message
  -idle-timeout duration
    	Maximum time a request could idle (default 1m0s)
  -insecure-skip-verify
    	Skip verify tls connection certificates (default true)
  -policy-file string
    	Policy file, will be reloaded on receiving signal SIGUSR1. If empty, default policy is: 
      <?xml version="1.0"?>
    	<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
    	<cross-domain-policy>
    	  <allow-access-from domain="*" to-ports="80-32767" />
    	</cross-domain-policy>
  -policy-idle-timeout duration
    	Maximum time a request for policy should take (default 3s)
  -profile-addr string
    	pprof service address, empty string disables profiling (default "127.0.0.1:6060")
  -serverlist string
    	server list json file path or url of configuration
  -tls-cert-file string
    	TLS certificate file; cert and key files will be reloaded on receiving signal SIGUSR1
  -tls-key-file string
    	TLS key file
  -version
    	print version number

- Samle serverlist.json

// supports comment line starting with '//'
{
  "__default__" : {
    "ssl": false
  },
  "api.example.com" : {
    "ip": "192.168.0.100",
    "port": "80,443,1024-30000",
    "ssl": true
  }
}

websocket-gateway's People

Contributors

xuwaters avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.