Coder Social home page Coder Social logo

flex_mysql_proxy's Introduction

flex_mysql_proxy

A MySQL Proxy with Dynamic Redirection.

It extract the “username” and “db” from the first client packet.

Then it asprintf(“%s.sql.example.net”) and connect to this backend, and thus forwards between the client and the backend.

Usage

pmake re [proxy_port=3307] && ./flex_mysql_proxy

You have to have an /etc/flex_mysql_proxy/scripts/proxy.lua:


function get_backend_from_username(username, db)
return db..“.sql.example.net”, “3306”
end

This script should return the backend IP, or whatever is supported by getaddrinfo() like a hostname.

It listen on the port 3307 by default.

Caveats

I am not a magician. This could not work with “mysql_native_password” authentication due to the challenge-response (there is some sort of a scramble).

You have to use “—enable-cleartext-plugin” which means that the backend is allowed to re-request the password in plain text.

It works:

  • with plaintext authentication (https://github.com/folays/mysql_auth_flex)
  • could work for PAM & co
  • could work with minimal modifications where we can discard and not considering the first backend packet (no challenge to be forcibly answered)
folays@phenix:~$ mysql -h 127.0.0.1 --port 3307--user=username --enable-cleartext-plugin --password=password

flex_mysql_proxy's People

Contributors

folays avatar quentinperez avatar

Stargazers

Gabriel Linder avatar

Watchers

Manfred Touron avatar James Cloos avatar  avatar

Forkers

quentinperez

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.