šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

github.com/doubledi/tcprate

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/doubledi/tcprate

v0.0.0-20221022183008-5b6bed26aa63
Source
Go
Version published
Created
Source

Throttling bandwidth with Go

Test

go test -v -timeout 300s

Example server usage

    limiter := tcprate.NewLimiter()
    l, err := net.Listen("tcp", addr)
    if err != nil {
        panic(err)
    }
    limiter.WithBandwith(10)
    for {
        conn, err := l.Accept()
        if err != nil {
            panic(err)
        }
        wrappedConn := limiter.WrapConn(conn)
        wrappedConn.WithBandwith(5)
        go handleConn(t, wrappedConn)
    }

FAQs

Package last updated on 22 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts