Giter Club home page Giter Club logo

ranch_proxy_protocol's Introduction

Ranch Proxy Protocol Socket

This module wraps the ranch_tcp module to parse the proxy protocol (version 1) before handing the socket on to the ranch handler.

It has the same API as the ranch_tcp module but with two new functions; connect/4 and proxyname/1.

The transport is called ranch_proxy.

connect/4

connect/4 allows you to connect with to a remote host, and sending the proxy protocol header automatically before going on to use the socket. It's similar to the regular ranch_tcp:connect/3 but accepts a third tuple containing proxy protocol information:

-type proxy_opts() :: [{inet_version, ipv4 | ipv6} |
                       {source_address, inet:ip_address() | inet:hostname()} |
                       {source_port, inet:port_number()} |
                       {dest_address, inet:ip_address() | inet:hostname()} |
                       {source_port, inet:port_number()}].
-spec connect(inet:ip_address() | inet:hostname(),
              inet:port_number(), any(), proxy_opts())
	-> {ok, #proxy_socket{}} | {error, atom()}.

proxyname/1

proxyname/1 gives you the proxy protocol information:

-type proxy_protocol_info() :: [{source_address, inet:ip_address()} |
                                {dest_address, inet:ip_address()} |
                                {source_port, inet:port_number()} |
                                {dest_port, inet:port_number()}].
-spec proxyname(proxy_socket()) ->
                       {ok, proxy_protocol_info()} | {error, atom()}.

Run the tests!

Sure why don't you

$ rebar3 ct

License

See the LICENSE file.

ranch_proxy_protocol's People

Contributors

omarkj avatar ferd avatar archaelus avatar joedevivo avatar tsloughter avatar acogoluegnes avatar danp avatar

Watchers

James Cloos avatar  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.