grpcSimple

package
v1.1.9-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package grpcHardcore implements grpc tunnel without importing google.golang.org/grpc.

Reference

https://github.com/Dreamacro/clash/blob/master/transport/gun/gun.go, which is under MIT license

在 clash的客户端实现 的 基础上 继续用 golang的 http2包 实现了 grpc 的 基本服务端,并改进了 原代码。

grpcSimple包 比grpc包 小很多,替代grpc包的话,可以减小 4MB 左右的可执行文件大小。但是目前不支持 multiMode。

grpcSimple包 是很棒 很有用的 实现,未来可以添加 针对 grpc的ServiceName的回落。

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLength = errors.New("invalid length")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Config
	// contains filtered or unexported fields
}

func (*Client) DialSubConn

func (c *Client) DialSubConn(underlay any) (net.Conn, error)

func (*Client) GetCommonConn

func (c *Client) GetCommonConn(underlay net.Conn) (any, error)

由于 本包应用了 http2包, 无法获取特定连接, 所以返回 underlay 本身

func (*Client) GetPath

func (c *Client) GetPath() string

func (*Client) IsEarly

func (c *Client) IsEarly() bool

func (*Client) IsMux

func (c *Client) IsMux() bool

func (*Client) IsSuper

func (c *Client) IsSuper() bool

func (*Client) ProcessWhenFull

func (c *Client) ProcessWhenFull(underlay any)

type ClientConn

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

implements net.Conn

func (*ClientConn) Close

func (g *ClientConn) Close() error

func (*ClientConn) LocalAddr

func (g *ClientConn) LocalAddr() net.Addr

func (*ClientConn) Read

func (g *ClientConn) Read(b []byte) (n int, err error)

func (*ClientConn) RemoteAddr

func (g *ClientConn) RemoteAddr() net.Addr

func (*ClientConn) SetDeadline

func (g *ClientConn) SetDeadline(t time.Time) error

func (*ClientConn) SetReadDeadline

func (g *ClientConn) SetReadDeadline(t time.Time) error

func (*ClientConn) SetWriteDeadline

func (g *ClientConn) SetWriteDeadline(t time.Time) error

func (*ClientConn) Write

func (g *ClientConn) Write(b []byte) (n int, err error)

type Config

type Config struct {
	ServiceName string
	Host        string
}

type Creator

type Creator struct{}

func (Creator) GetDefaultAlpn

func (Creator) GetDefaultAlpn() (alpn string, mustUse bool)

func (Creator) NewClientFromConf

func (Creator) NewClientFromConf(conf *advLayer.Conf) (advLayer.Client, error)

func (Creator) NewServerFromConf

func (Creator) NewServerFromConf(conf *advLayer.Conf) (advLayer.Server, error)

func (Creator) PackageID

func (Creator) PackageID() string

type Server

type Server struct {
	Config

	http2.Server
	// contains filtered or unexported fields
}

func (*Server) GetPath

func (s *Server) GetPath() string

func (*Server) IsMux

func (*Server) IsMux() bool

func (*Server) IsSuper

func (*Server) IsSuper() bool

func (*Server) StartHandle

func (s *Server) StartHandle(underlay net.Conn, newSubConnChan chan net.Conn)

type ServerConn

type ServerConn struct {
	io.Closer
	io.Writer
	// contains filtered or unexported fields
}

func (*ServerConn) Close

func (g *ServerConn) Close() error

func (*ServerConn) LocalAddr

func (g *ServerConn) LocalAddr() net.Addr

func (*ServerConn) Read

func (g *ServerConn) Read(b []byte) (n int, err error)

func (*ServerConn) RemoteAddr

func (g *ServerConn) RemoteAddr() net.Addr

func (*ServerConn) SetDeadline

func (g *ServerConn) SetDeadline(t time.Time) error

func (*ServerConn) SetReadDeadline

func (g *ServerConn) SetReadDeadline(t time.Time) error

func (*ServerConn) SetWriteDeadline

func (g *ServerConn) SetWriteDeadline(t time.Time) error

func (*ServerConn) Write

func (g *ServerConn) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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