~/bend-docscommunity

src/net.bend relies on unsafe/foreign

raw source on the hub · import bend-kube-runtime@0.1.1.0/src/net.bend as Net

2 imports
import Base
import ./proxy.bend as P

Types

type Tls source · line 12 · raw

Type

type Bytes source · line 15 · raw

Data

type TunEv source · line 63 · raw

Type

What the CONNECT exchange just saw.

Definitions

def Res source · line 18 · raw

@-A:Type -> Type

def Tls.fail source · line 59 · raw

@s:Socket -> @e:Pair(U32, String) -> IO(Res(Socket))

def TunEv.got source · line 67 · raw

@p:Pair(Socket, Res(List<&2, U32>)) -> @st:0x7222ee9dc1fb2fecc4a955ab3997433b/src/proxy.Tunnel -> TunEv

def Tls.tunnel source · line 74 · 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 93 · 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 101 · 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 110 · raw

@d:Res(Socket) -> @+host:String -> @ca:String -> @cert:String -> @key:String -> @+ms:U32 -> IO(Res(Socket))

def Tls.open.route source · line 118 · raw

@r:0x7222ee9dc1fb2fecc4a955ab3997433b/src/proxy.Route -> @+host:String -> @+port:U32 -> @ca:String -> @cert:String -> @key:String -> @+ms:U32 -> IO(Res(Socket))

def Tls.env.or source · line 130 · raw

@r:Res(String) -> @alt:Res(String) -> String

def Tls.env source · line 141 · 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.open source · line 148 · raw

@+host:String -> @+port:U32 -> @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).

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.recv source · line 48 · 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 52 · raw

@sock:Socket -> IO(Unit)

foreign: src/effs/tls.c, src/effs/tls.js