src/net.bend relies on unsafe/foreign
raw source on the hub · import bend-kube-runtime@0.5.3.0/src/net.bend as Net
2 imports
import Base import ./proxy.bend as P
Types
type Tls source · line 12 · raw
Type
Tls@sock:Socket -> Tls
type Bytes source · line 15 · raw
Data
Bytes@list:List<&2, U32> -> Bytes
type TunEv source · line 68 · raw
Type
What the CONNECT exchange just saw.
TGot@sock:Socket -> @r:Res(List<&2, U32>) -> @st:0x4b19fea9f3c794558ea41a0289840d6a/src/proxy.Tunnel -> TunEv
TStep@sock:Socket -> @st:0x4b19fea9f3c794558ea41a0289840d6a/src/proxy.Tunnel -> TunEv
Definitions
def Res source · line 18 · raw
@-A:Type -> Type
def Tls.fail source · line 64 · raw
@s:Socket -> @e:Pair(U32, String) -> IO(Res(Socket))
def TunEv.got source · line 72 · raw
@p:Pair(Socket, Res(List<&2, U32>)) -> @st:0x4b19fea9f3c794558ea41a0289840d6a/src/proxy.Tunnel -> TunEv
def Tls.tunnel source · line 79 · raw
@fuel:Nat -> @ev:TunEv -> @+host:String -> @ca:String -> @cert:String -> @key:String -> @+ms:U32 -> IO(Res(Socket))
Reads the proxy's answer to CONNECT; once it opens the tunnel, secures the connection end to end with the API server.
def Tls.open.sent source · line 98 · raw
@p:Pair(Socket, Res(Unit)) -> @+host:String -> @ca:String -> @cert:String -> @key:String -> @+ms:U32 -> IO(Res(Socket))
def Tls.open.proxied source · line 106 · raw
@d:Res(Socket) -> @req:String -> @+host:String -> @ca:String -> @cert:String -> @key:String -> @+ms:U32 -> IO(Res(Socket))
def Tls.open.direct source · line 115 · raw
@d:Res(Socket) -> @+host:String -> @ca:String -> @cert:String -> @key:String -> @+ms:U32 -> IO(Res(Socket))
def Tls.open.route source · line 125 · raw
@r:0x4b19fea9f3c794558ea41a0289840d6a/src/proxy.Route -> @+host:String -> @+port:U32 -> @+vh:String -> @ca:String -> @cert:String -> @key:String -> @+ms:U32 -> IO(Res(Socket))
vh is the name the server's certificate must carry (and the SNI sent); host:port is where to connect.
def Tls.env.or source · line 137 · raw
@r:Res(String) -> @alt:Res(String) -> String
def Tls.env source · line 148 · raw
@name:String -> @alt:String -> IO(String)
The first of two environment variables that is set and not empty, as Go reads HTTPS_PROXY then https_proxy.
def Tls.vname source · line 152 · raw
@+host:String -> @+name:String -> @none:Bool -> String
def Tls.open source · line 164 · raw
@+host:String -> @+port:U32 -> @+name:String -> @ca:String -> @cert:String -> @key:String -> @+ms:U32 -> IO(Res(Socket))
Opens a verified TLS connection to host:port (see Tls.secure), through the CONNECT tunnel of HTTPS_PROXY unless NO_PROXY or a loopback host says otherwise (proxy.bend). name, when not empty, is what the server's certificate must carry and the SNI sent, instead of host (kubeconfig's tls-server-name, client-go's TLSClientConfig.ServerName).
Effects (foreign code)
effect Tls.dial source · line 27 · raw
@host:String -> @port:U32 -> @ms:U32 -> IO(Res(Socket))
A plain TCP connection: host may be a name (resolved, IPv4 or IPv6) or an IP literal; ms bounds the connect (0 for 30s). Until Tls.secure, Tls.send and Tls.recv carry its bytes as they are.
foreign: src/effs/tls.c, src/effs/tls.js
effect Tls.secure source · line 36 · raw
@sock:Socket -> @host:String -> @ca:String -> @cert:String -> @key:String -> @ms:U32 -> IO(Res(Socket))
Handshakes on a connection from Tls.dial and verifies the server as host (a name, or an IP literal), always: ca is a PEM bundle of trusted roots ("" for the system's), cert and key a PEM client certificate and key ("" for none), ms the handshake's deadline (0 for 30s). TLS 1.2 or later. A failure closes the connection.
foreign: src/effs/tls.c, src/effs/tls.js
effect Tls.send source · line 42 · raw
@sock:Socket -> @text:String -> @ms:U32 -> IO(Pair(Socket, Res(Unit)))
Sends text as UTF-8; ms bounds the whole send (0: no deadline).
foreign: src/effs/tls.c, src/effs/tls.js
effect Tls.send_bytes source · line 47 · raw
@sock:Socket -> @bytes:List<&2, U32> -> @ms:U32 -> IO(Pair(Socket, Res(Unit)))
Sends raw bytes (each 0..255); ms bounds the whole send (0: no deadline).
foreign: src/effs/tls.c, src/effs/tls.js
effect Tls.recv source · line 53 · raw
@sock:Socket -> @max:U32 -> @ms:U32 -> IO(Pair(Socket, Res(List<&2, U32>)))
Up to max bytes (0: 16KiB); an empty list is the end of the stream. ms bounds the wait (0: none), past which it fails with ETIMEDOUT (60).
foreign: src/effs/tls.c, src/effs/tls.js
effect Tls.close source · line 57 · raw
@sock:Socket -> IO(Unit)
foreign: src/effs/tls.c, src/effs/tls.js