internal

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addr2UCred

func Addr2UCred(str string) (pid, uid int)

Addr2UCred 从字符串地址中解码出UCred2Addr编码的pid和uid

func DuplexConnCtrlFd

func DuplexConnCtrlFd(conn net.Conn) error

DuplexConnCtrlFd 将连接配置为控制信道

func DuplexConnDataRpc

func DuplexConnDataRpc(conn net.Conn) error

DuplexConnDataRpc 将连接配置为数据信道

func GetInjectKey

func GetInjectKey() string

GetInjectKey 返回Exec服务时应当注入的环境变量名称

func GetInjectValue

func GetInjectValue() string

GetInjectValue 从环境变量中获取到来自Ally注入的通信地址信息

func GetUCred

func GetUCred(c *net.UnixConn) (int, int, error)

GetUCred 从unix socket中提取pid和uid

func ListenFile

func ListenFile(network, address string) (*os.File, string, error)

ListenFile 将Listen给定的地址,并将得到的Listenr或者PacketConn的提取*os.File返回

func ListenSocket

func ListenSocket(network, address string) (net.Listener, net.PacketConn, error)

ListenSocket 统一Listener和PacketConn的Listen方式

func RecvFile

func RecvFile(via *net.UnixConn) (*os.File, error)

RecvFile 从给定的unix socket中接收一个fd并转换为*os.File

func ResolveAddress

func ResolveAddress(network, address string) (net.Addr, error)

ResolveAddress 解析全部支持的协议地址

func SendFile

func SendFile(via *net.UnixConn, file *os.File) error

SendFile 将给定*os.File的fd通过unix socket发送出去

func TLSClientConn

func TLSClientConn(raw *net.UnixConn) *tls.Conn

func TLSServerConn

func TLSServerConn(raw *net.UnixConn) *tls.Conn

func UCred2Addr

func UCred2Addr(pid, uid int) string

UCred2Addr 将pid和uid做简单的一次编码,融合为一个字符串

Types

type UnixConn

type UnixConn struct {
	*tls.Conn
	// contains filtered or unexported fields
}

UnixConn 包装了原始的tls.Conn,目标是为了能够将连接对端的pid和uid给拿到,并能传递给到grpc的业务功能

func (*UnixConn) RemoteAddr

func (c *UnixConn) RemoteAddr() net.Addr

type UnixListener

type UnixListener struct {
	*net.UnixListener

	// HijackCtrlFd 允许从连接中分类控制信道
	HijackCtrlFd func(*net.UnixConn)
}

UnixListener 包装了标准库的UnixListener,主要是为了能在grpc场景中,能拦截grpc创建的连接。 grpc对连接的包装层次较深,无法简单的得到请求归属的原始连接,只能出此下策

func (*UnixListener) Accept

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

Accept 获取新连接,如果是数据信道,则返回上层共grpc使用,如果是控制信道,则交给HijackCtrlFd处理

Jump to

Keyboard shortcuts

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