Giter Site home page Giter Site logo

spike's Introduction

Software License Build Status Coverage Status Latest Stable Version Scrutinizer

Spike is a fast reverse proxy built on top of ReactPHP that helps to expose your local services to the internet.

简体中文

Installation

Install via composer

composer global require slince/spike

Both the server and local machine need to install this.

Schematic diagram

Configure the server

A public machine that can be accessed on the internet is needed. Assuming already. There are two ways to start the server

Based on defaults

Use the following command to start the server

$ spiked --address=127.0.0.1:8088

The above command can create a basic service. If you want to customize more information, you should start the server based on the configuration file.

Based on the configuration file.

  • Creates a configuration file

Execute the following command to create it.

$ spiked init --dir=/home/conf --format=json

Yaml,Xml,Ini and Json(default) files are supported. Use the following command for help.

$ spiked init -h
  • Open the configuration file and modify the parameters.

  • Executes the following command to start the service.

 $ spiked --config=/home/conf/spiked.json

Configure the client.

You should first create a configuration file for the client.

  • Execute the following command to create it
$ spike init --dir=/home/conf --format=json

Use the following command for help about this command

$ spike init -h
  • Open the configuration file and modify the parameters.

  • Start the client service.

$ spike --config=/home/conf/spike.json

Tunnel

The definition of the tunnel only in the client, the server does not need to do any configuration, so as to achieve the most simplified configuration.

Now supports both http and tcp tunnels

Open the configuration file for the client and modify the parameters for "tunnel".

  • Add an HTTP tunnel
{
    "protocol": "http",
    "serverPort": 8086,
    "proxyHosts": {
        "www.foo.com": "127.0.0.1:80",
        "www.bar.com": "192.168.1.101:8080"
    }
}

Restarts the client service. Visit "http://www.foo.com:8086", the service will be forwarded to the local "127.0.0.1:80"; Note that resolve "www.foo.com" to the server IP.

  • Add a TCP tunnel

The services based on the tcp can use the tunnel, such as: mysql, redis, ssh and so on; The following is an example of proxy mysql service

{
    "protocol": "tcp",
    "serverPort": 8087,
    "host": "127.0.0.1:3306"
}

Execute the following command to visit the local mysql service.

$ mysql -h SERVER IP -P 8087

Client authentication

The authentication is not enabled on the server based on defaults.You should start the server based on configuration file, if you want to enable this.

  • Enable authentication

Open the configuration file for the server and modify parameters for "auth" and restart the service.

Currently only supports a simple user name password authentication, more authentication methods will be added later.

  • Modify the client identity information

Open the configuration file for the client and modify parameters for "auth". Keep the same parameters as the server.

Configure log

The default to open the console and file two forms of the log; the first will print the logs to the console; the second will write all the logs to the specified file; Default log level is "info"; You can adjust this in the configuration file.

List Commands

$ spike list
   _____   _____   _   _   _    _____
  /  ___/ |  _  \ | | | | / /  | ____|
  | |___  | |_| | | | | |/ /   | |__
  \___  \ |  ___/ | | | |\ \   |  __|
   ___| | | |     | | | | \ \  | |___
  /_____/ |_|     |_| |_|  \_\ |_____|
  
  Spike Client 0.0.1
  
  Usage:
    command [options] [arguments]
  
  Options:
    -h, --help            Display this help message
    -q, --quiet           Do not output any message
    -V, --version         Display this application version
        --ansi            Force ANSI output
        --no-ansi         Disable ANSI output
    -n, --no-interaction  Do not ask any interactive question
    -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
  
  Available commands:
    help        Displays help for a command
    init        Create a configuration file in the specified directory
    list        Lists commands
    list-proxy  Lists all supported proxy hosts by the client

Changelog

See CHANGELOG.md

License

The MIT license. See MIT

spike's People

Contributors

slince avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spike's Issues

路由重启后,一直没有重连……

路由重启后,一直没有重连(Spike),

我看服务器配置,隧道还在线,实际上肯定连不上了,

然后我将服务器(spiked)也重启,还是没有重连。

如果禁用了两个函数。服务启动不起来

如果禁用函数proc_open和stream_socket_server两个函数将会报错(默认lnmp是禁用的)

PHP Warning: stream_set_blocking() expects parameter 1 to be resource, null given in /root/.config/composer/vendor/react/socket/src/TcpServer.php on line 166
[2018-08-17 17:43:18] INFO: The server is running ...
[2018-08-17 17:43:48] INFO: Client Total: 0; Chunk Server Total: 0
[2018-08-17 17:44:18] INFO: Memory usage: 2523784

但是服务并没有起来。建议添加这两个函数的禁用情况进行异常处理。

解决办法:修复php.ini将这两个函数启用。

server端运行报错

image

[2018-06-05 14:07:13] INFO: The server is running ...
PHP Fatal error:  Uncaught TypeError: Argument 2 passed to Spike\Timer\Timer::activate() must be an instance of React\EventLoop\Timer\TimerInterface, instance of React\EventLoop\Timer\Timer given, called in /home/deploy/.config/composer/vendor/slince/spike/src/Timer/UseTimerTrait.php on line 29 and defined in /home/deploy/.config/composer/vendor/slince/spike/src/Timer/Timer.php:26
Stack trace:
#0 /home/deploy/.config/composer/vendor/slince/spike/src/Timer/UseTimerTrait.php(29): Spike\Timer\Timer->activate(Object(React\EventLoop\StreamSelectLoop), Object(React\EventLoop\Timer\Timer))
#1 /home/deploy/.config/composer/vendor/slince/spike/src/Server/Server.php(120): Spike\Server\Server->addTimer(Object(Spike\Server\Timer\ReviewClient))
#2 /home/deploy/.config/composer/vendor/slince/spike/src/Server/Application.php(93): Spike\Server\Server->run()
#3 /home/deploy/.config/composer/vendor/slince/spike/src/Server/Application.php(79): Spike\Server\Application->runServer()
#4 /home/deploy/.config/composer/vendor/slince/spike/src/Server/A in /home/deploy/.config/composer/vendor/slince/spike/src/Timer/Timer.php on line 26

php版本

[deploy@code-1000 ~]$ php -v
PHP 7.0.29 (cli) (built: Apr  1 2018 00:08:23) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.29, Copyright (c) 1999-2017, by Zend Technologies

Http可用,TCP不可用

在使用Http 穿透的时候,一切都正常。
在使用tcp穿透都时候,始终是连接中,日志也显示正常,但是始终连接不上。

测试过3306连接mysql,也测试过3389连接windows远程,均无法连接,一直显示连接中。

服务端:centos
客户端:macos

备注:代理端口也都开着。

第二次补充:
发现并不是连接不上,而是需要不断的断开连接、重新连接,才能连接上

spike: command not found

已进行composer全局安装,切换到安装包bin目录下也无法使用命令
spike: command not found

运行大概6小时之后,tpc隧道会无法连接,http隧道正常

前天晚上开始使用,发现一觉睡醒就再也连不上tcp隧道了
昨晚又测试了一次,在睡觉前测试时可以连接,睡醒之后就无法连接了,重启客户端恢复正常,我睡觉时间大概5小时,加上睡前的重启行为,推测大概在6小时最后tcp的隧道就会挂掉

还有以下的问题:
服务端重启了服务,tpc隧道会不可用(http正常)

客户端环境:ubuntu 16.04位
php:7.1.6

服务端环境:ubuntu-14.04 64位
php:7.1.3

服务端启动成功 客户端连不上

服务端启动成功 客户端连不上

用namp检查了端口是开放的

客户端报错

$ spike --config=./spike_conf/spike.json -vvv                                                                            [20:08:15]
[2018-06-05 20:08:21] INFO: The client is running ...
[2018-06-05 20:08:21] ERROR: Cannot connect to the server. the server may not be available

能实现p2p通信吗

可不可以不使用服务器转发,在网络条件允许的情况下使用P2P连接。而spike服务端只做“打洞”。

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.