Giter VIP home page Giter VIP logo

portproxy's Introduction

portproxy

A TCP port proxy utility inspired by qtunnel(https://github.com/getqujing/qtunnel).

note: portproxy does not suport ssl mode(mysql 5.7/8.0 client), only used in test environments.

How to Install

go get github.com/arstercz/portproxy

Usage

Usage of ./portproxy:
  -backend string
        backend server ip and port (default "127.0.0.1:8003")
  -bind string
        locate ip and port (default ":8002")
  -buffer uint
        buffer size (default 4096)
  -conf string
        config file to verify database and record sql query
  -daemon
        run as daemon process
  -logTo string
        stdout or syslog (default "stdout")
  -verbose
        print verbose sql query

portproxy only print mysql queries when conf is not set:

./portproxy -backend="10.0.21.5:3301" -bind=":3316" -buffer=16384  --verbose
2017/01/12 17:27:23 portproxy started.
2017/01/12 17:27:32 client: 10.0.21.7:29110 ==> 10.0.21.5:3316
2017/01/12 17:27:32 proxy: 10.0.21.5:18386 ==> 10.0.21.5:3301
2017/01/12 17:27:32 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: select @@version_comment limit 1
2017/01/12 17:27:48 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: SELECT DATABASE()
2017/01/12 17:27:48 From 10.0.21.7:29110 To 10.0.21.5:3301; schema: use percona
2017/01/12 17:27:48 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: show databases
2017/01/12 17:27:49 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: show tables
2017/01/12 17:27:49 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: table columns list: item
2017/01/12 17:27:49 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: table columns list: stock
2017/01/12 17:27:56 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: show tables
2017/01/12 17:28:01 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: show create table item
2017/01/12 17:28:04 From 10.0.21.7:29110 To 10.0.21.5:3301; Query: kill 2

changelog:

20200423: skip error when does not set conf option
20170112: log mysql query

portproxy's People

Contributors

arstercz avatar subvillion 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

Watchers

 avatar  avatar  avatar  avatar

portproxy's Issues

Errors with goconfig library when trying to run app

Replicated on go version go1.13.4 linux/amd64 and go version go1.14.2 linux/amd64

Getting an issue with the goconfig library when I trry to run this app, looks like its trying to init an input which dosent exist, is there a config file I should be adding ? I did notice there is a conf flag in main.go since the initial commit however I cant work out why this error is happening.

The port is free and the sql server is resolvable / reachable.

./portproxy backend="server.address.net:3306" -bind="33075" -buffer=4096 -daemon=false -logTo="stdout"

2020/04/23 04:32:40 Can't get config info, skip insert log to mysql...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4ebe96]

goroutine 1 [running]:
github.com/arstercz/goconfig.(*ConfigFile).GetRawString(0x0, 0x6b41c0, 0x7, 0x6b3969, 0x3, 0x605f7a, 0x0, 0x0, 0xc000093f90)
        /root/go/src/github.com/arstercz/goconfig/configfile.go:427 +0x96
github.com/arstercz/goconfig.(*ConfigFile).GetString(0x0, 0x6b41c0, 0x7, 0x6b3969, 0x3, 0x0, 0x30, 0x6b3ce4, 0xc000093e98)
        /root/go/src/github.com/arstercz/goconfig/configfile.go:448 +0x74
main.get_backend_dsn(...)
        /root/go/src/github.com/arstercz/portproxy/conf.go:17
main.main()
        /root/go/src/github.com/arstercz/portproxy/main.go:66 +0x4b9

Query log not printing to stdout

On testing the app I have noticed that when connecting to a sql server only the client and proxy information is printing however the query log does not print.

example:

2020/04/24 03:34:10 client: 10.38.5.158:53236 ==> 10.38.20.178:33075
2020/04/24 03:34:10 proxy: 10.38.20.178:39012 ==> 10.38.31.245:3306
2020/04/24 03:34:23 client: 10.38.5.158:53238 ==> 10.38.20.178:33075
2020/04/24 03:34:23 proxy: 10.38.20.178:39014 ==> 10.38.31.245:3306
2020/04/24 03:34:23 r: 3394 w:0 ct:0.001 t:0.273 [#2]
2020/04/24 03:34:23 client: 10.38.5.158:53240 ==> 10.38.20.178:33075
2020/04/24 03:34:23 proxy: 10.38.20.178:39016 ==> 10.38.31.245:3306
2020/04/24 03:34:24 r: 3394 w:0 ct:0.001 t:0.692 [#2]
2020/04/24 03:34:24 client: 10.38.5.158:53242 ==> 10.38.20.178:33075
2020/04/24 03:34:24 proxy: 10.38.20.178:39018 ==> 10.38.31.245:3306
2020/04/24 03:34:24 r: 3394 w:0 ct:0.001 t:0.215 [#2]

Ran some select statements successfully when these sessions were enabled.

portproxy totp feature question

hello ,I want use the totp feature (user connect portproxy with username(mysql -u option) and password(username + (6 bit number from totp) by default);

example:

first:
./portproxy -backend="127.0.0.1:3306" -bind="0.0.0.0:3316" -conf="conf.cnf" -buffer=16384
2020/04/28 15:59:58 portproxy started.
second:
sys-google-totp --secret OJ3UAWO4CIB7M3DQ
totp message:
secret: OJ3UAWO4CIB7M3DQ
671114 (20 second(s) remaining)

starting the program,but I don‘t ’understand the logic
test demo:

mysql -u127.0.0.1 -P3316 -utest -ptest671114
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'test'@'localhost' (using password: YES)

the conf.cnf- [onlineread] configure is correct,what should i do ?

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.