trojan

package module
v0.0.0-...-f5f65c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

README

Caddy-Trojan

Build with xcaddy

$ xcaddy build --with github.com/wen-long/caddy-trojan

Config (JSON)

{
  "apps": {
    "http": {
      "http_port": 1999,
      "servers": {
        "srv0": {
          "listen": [
            ":443"
          ],
          "listener_wrappers": [
            {
              "users": [
                "username1",
                "username2"
              ],
              "wrapper": "trojan"
            }
          ],
          "routes": [
            {
              "handle": [
                {
                  "handler": "subroute",
                  "routes": [
                    {
                      "handle": [
                        {
                          "handler": "reverse_proxy",
                          "upstreams": [
                            {
                              "dial": "127.0.0.1:80"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "tls_connection_policies": [
            {
              "alpn": [
                "http/1.1"
              ]
            }
          ]
        }
      }
    },
    "tls": {
      "certificates": {
        "automate": [
          "your.domain.com"
        ]
      }
    }
  }
}

Config (Caddyfile)

{
   http_port 1999
   servers {
      listener_wrappers {
         trojan {
             user username1
             user username2
         }
      }
   }
}

:443, your.domain.com {
   tls {
      alpn http/1.1
   }
   route {
      reverse_proxy 127.0.0.1:80
   }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener struct {
	Verbose bool `json:"verbose,omitempty"`

	// Listener is ...
	net.Listener
	// Logger is ...
	Logger *zap.Logger
	// contains filtered or unexported fields
}

Listener is ...

func NewListener

func NewListener(ln net.Listener, logger *zap.Logger) *Listener

NewListener is ...

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept is ...

func (*Listener) Close

func (l *Listener) Close() error

Close is ...

type ListenerWrapper

type ListenerWrapper struct {
	// Logger is ...
	Logger    *zap.Logger `json:"-,omitempty"`
	UserLists []string    `json:"users"`
}

ListenerWrapper implements an TLS wrapper that it accept connections from clients and check the connection with pre-defined password and return a normal page if failed.

func (ListenerWrapper) CaddyModule

func (ListenerWrapper) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*ListenerWrapper) Provision

func (m *ListenerWrapper) Provision(ctx caddy.Context) error

Provision implements caddy.Provisioner.

func (*ListenerWrapper) UnmarshalCaddyfile

func (m *ListenerWrapper) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile unmarshals Caddyfile tokens into h.

func (*ListenerWrapper) ValidateUser

func (m *ListenerWrapper) ValidateUser(user string) bool

func (*ListenerWrapper) WrapListener

func (m *ListenerWrapper) WrapListener(l net.Listener) net.Listener

WrapListener implements caddy.ListenWrapper

type UserValidateFunc

type UserValidateFunc func(string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL