tunnel

package
v0.0.0-...-e4aa106 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2014 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidBlockData error = errors.New("invalid block data")
View Source
var RequestTimeout error = errors.New("request timeout")

Functions

func DecryptBlocks

func DecryptBlocks(b cipher.Block, bs []byte) error

func EncryptBlocks

func EncryptBlocks(b cipher.Block, bs []byte) error

func GenerateRSAKey

func GenerateRSAKey(bits int, path string) (*rsa.PrivateKey, error)

func LoadRSAPrivateKey

func LoadRSAPrivateKey(path string) (*rsa.PrivateKey, error)

func LoadRSAPublicKey

func LoadRSAPublicKey(path string) (*rsa.PublicKey, error)

func LoadYamlConfig

func LoadYamlConfig(path string, obj interface{}) error

func MakeCryptoKeyIV

func MakeCryptoKeyIV(password []byte, key_size, iv_size int) ([]byte, []byte)

func ReadN2

func ReadN2(bs []byte, offset int) uint16

func ReadN4

func ReadN4(bs []byte, offset int) uint32

func WriteN2

func WriteN2(bs []byte, offset int, n uint16)

func WriteN4

func WriteN4(bs []byte, offset int, n uint32)

Types

type AESCipherMaker

type AESCipherMaker struct{}

func (*AESCipherMaker) NewCipher

func (m *AESCipherMaker) NewCipher(key) (cipher.Block, error)

type CipherConfig

type CipherConfig struct {
	Name      string
	KeySize   int
	BlockSize int
	// contains filtered or unexported fields
}

func GetCipherConfig

func GetCipherConfig(name string) *CipherConfig

func (*CipherConfig) NewCipher

func (ctx *CipherConfig) NewCipher(key) (cipher.Block, error)

type CipherExchange

type CipherExchange struct {
	P         *big.Int
	G         int
	XY        *big.Int
	EF        *big.Int
	Key       *big.Int
	CryptoKey []byte // fixed size key, for cipher
	IV        []byte
}

func MakeCipherExchange

func MakeCipherExchange(p *big.Int, g int) *CipherExchange

func NewCipherExchange

func NewCipherExchange(group int) (*CipherExchange, error)

func (*CipherExchange) CalcKey

func (ctx *CipherExchange) CalcKey(ef *big.Int)

func (*CipherExchange) MakeCryptoKeyIV

func (ctx *CipherExchange) MakeCryptoKeyIV(key_size, iv_size int) ([]byte, []byte)

func (*CipherExchange) MakeE

func (ctx *CipherExchange) MakeE() (*big.Int, error)

func (*CipherExchange) MakeEF

func (ctx *CipherExchange) MakeEF(minval int64) (*big.Int, error)

func (*CipherExchange) MakeF

func (ctx *CipherExchange) MakeF() (*big.Int, error)

func (*CipherExchange) MakeSessionId

func (ctx *CipherExchange) MakeSessionId() (SessionId, error)

type ClientConfig

type ClientConfig struct {
	ServerAddr string

	GlobalEncryptMethod   string
	GlobalEncryptPassword string
	LinkEncryptMethods    []string
	ServerPublicKeyPath   string

	Username string
	Password string
}

func LoadClientConfig

func LoadClientConfig(path string) (*ClientConfig, error)

type DESCipherMaker

type DESCipherMaker struct {
	// contains filtered or unexported fields
}

func (*DESCipherMaker) NewCipher

func (m *DESCipherMaker) NewCipher(key) (cipher.Block, error)

type GlobalCipherConfig

type GlobalCipherConfig struct {
	Config *CipherConfig
	Key    []byte
}

func LoadGlobalCipherConfig

func LoadGlobalCipherConfig(name string, passwd []byte) (*GlobalCipherConfig, error)

func (*GlobalCipherConfig) NewCipher

func (cfg *GlobalCipherConfig) NewCipher() (cipher.Block, error)

type RetryRequester

type RetryRequester struct {
	// contains filtered or unexported fields
}

func NewRetryRequester

func NewRetryRequester(max_retry, timeout int, read, write chan []byte) *RetryRequester

func (*RetryRequester) Request

func (req *RetryRequester) Request(data []byte) ([]byte, error)

func (*RetryRequester) RetryGet

func (req *RetryRequester) RetryGet(max_retry int) ([]byte, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *ServerConfig) (*Server, error)

func (*Server) Close

func (ser *Server) Close() error

func (*Server) Run

func (ser *Server) Run()

type ServerConfig

type ServerConfig struct {
	ListenAddr            string
	GlobalEncryptMethod   string
	GlobalEncryptPassword string
	LinkEncryptMethods    []string

	UserConfigPath string
	KeyPath        string
}

func LoadServerConfig

func LoadServerConfig(path string) (*ServerConfig, error)

type Session

type Session struct {
	Id         SessionId
	RemoteAddr *net.UDPAddr
	Username   string
	// contains filtered or unexported fields
}

func NewSession

func NewSession(sid SessionId, addr *net.UDPAddr) *Session

func (*Session) Close

func (session *Session) Close()

func (*Session) Run

func (session *Session) Run()

type SessionId

type SessionId string

func SessionIdFromBytes

func SessionIdFromBytes(bs []byte) SessionId

func (SessionId) Bytes

func (sid SessionId) Bytes() ([]byte, error)

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

func NewSessionManager

func NewSessionManager() *SessionManager

func (*SessionManager) AutoDelSession

func (mgr *SessionManager) AutoDelSession()

func (*SessionManager) DelSession

func (mgr *SessionManager) DelSession(session *Session)

func (*SessionManager) DelSessionById

func (mgr *SessionManager) DelSessionById(sid SessionId)

func (*SessionManager) GetSessionByAddr

func (mgr *SessionManager) GetSessionByAddr(addr string) *Session

func (*SessionManager) GetSessionById

func (mgr *SessionManager) GetSessionById(sid SessionId) *Session

func (*SessionManager) NewSession

func (mgr *SessionManager) NewSession(addr *net.UDPAddr) *Session

func (*SessionManager) SessionFeedId

func (mgr *SessionManager) SessionFeedId(session *Session, sid SessionId)

type TunDev

type TunDev interface {
	SetLocalAddr(ip net.IP) error
	SetRemoteAddr(ip net.IP) error
	SetMTU(mtu int) error

	Read(bs []byte) (int, error)
	Write(bs []byte) (int, error)
	Close() error
}

type UserConfig

type UserConfig struct {
	Password string
}

type UserConfigs

type UserConfigs struct {
	// contains filtered or unexported fields
}

func GetUserConfigs

func GetUserConfigs(path string) (*UserConfigs, error)

func (*UserConfigs) Get

func (cfgs *UserConfigs) Get(user string) *UserConfig

func (*UserConfigs) Reload

func (cfgs *UserConfigs) Reload() error

Jump to

Keyboard shortcuts

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