{"id":30030059,"url":"https://github.com/asticode/go-astisrt","last_synced_at":"2025-09-21T19:06:19.094Z","repository":{"id":59090410,"uuid":"534938758","full_name":"asticode/go-astisrt","owner":"asticode","description":"SRT server, client and socket in GO","archived":false,"fork":false,"pushed_at":"2024-09-24T12:39:12.000Z","size":44,"stargazers_count":46,"open_issues_count":0,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-24T12:50:44.868Z","etag":null,"topics":["client","go","golang","server","socket","srt"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asticode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-10T08:32:29.000Z","updated_at":"2025-07-25T15:12:35.000Z","dependencies_parsed_at":"2024-06-19T05:22:34.149Z","dependency_job_id":"8c7fe52e-5993-4182-a329-25dc737e0afe","html_url":"https://github.com/asticode/go-astisrt","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/asticode/go-astisrt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astisrt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astisrt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astisrt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astisrt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asticode","download_url":"https://codeload.github.com/asticode/go-astisrt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astisrt/sbom","scorecard":{"id":213390,"data":{"date":"2025-08-11","repo":{"name":"github.com/asticode/go-astisrt","commit":"7f3d215981b5230f717163bc3504fbfe7fe07f35"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/14 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/asticode/go-astisrt/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/asticode/go-astisrt/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/asticode/go-astisrt/test.yml/master?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/test.yml:74","Info:   0 out of   3 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T01:10:05.186Z","repository_id":59090410,"created_at":"2025-08-17T01:10:05.187Z","updated_at":"2025-08-17T01:10:05.187Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276289942,"owners_count":25617000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","go","golang","server","socket","srt"],"created_at":"2025-08-06T18:50:53.338Z","updated_at":"2025-09-21T19:06:19.089Z","avatar_url":"https://github.com/asticode.png","language":"Go","readme":"[![GoReportCard](http://goreportcard.com/badge/github.com/asticode/go-astisrt)](http://goreportcard.com/report/github.com/asticode/go-astisrt)\n[![GoDoc](https://godoc.org/github.com/asticode/go-astisrt?status.svg)](https://godoc.org/github.com/asticode/go-astisrt)\n[![Test](https://github.com/asticode/go-astisrt/actions/workflows/test.yml/badge.svg)](https://github.com/asticode/go-astisrt/actions/workflows/test.yml)\n[![Coveralls](https://coveralls.io/repos/github/asticode/go-astisrt/badge.svg?branch=master)](https://coveralls.io/github/asticode/go-astisrt)\n\n# SRT server, client and socket in GO\n\nFirst off, a big thanks to the [official GO bindings](https://github.com/Haivision/srtgo) that was an amazing source of inspiration for this project.\n\nHowever a few things bothered me in it therefore I decided to write my own bindings with a few goals in mind:\n\n- [x] split the API between both high level entities, similar to GO's `net/http` entities, with very guided methods (`ListenAndServe`, `Shutdown`, `Dial`, `Read`, `Write` etc.) and low level entities, closer to C, with I-should-know-what-I-am-doing-before-using-them methods (`Socket`, etc.)\n- [x] provide named and typed option setters and getters\n- [x] make sure all errors are handled properly since they are thread-stored and ban the use of runtime.LockOSThread()\n- [x] make sure there's a context specific to each connection in high level methods\n- [x] make sure pointers are the same between the `ListenCallback` and `Accept()`, and between the `ConnectCallback` and `Connect()` \n- [x] only use blocking mode in high level entities\n\n`astisrt` has been tested on `v1.5.3`.\n\n## Examples\n\nExamples are located in the [examples](examples) directory\n\nWARNING: the code below doesn't handle errors for readibility purposes. However you SHOULD!\n\n### Server\n\n[Go to full example](examples/server/main.go)\n\n```go\n// Capture SIGTERM\ndoneSignal := make(chan os.Signal, 1)\nsignal.Notify(doneSignal, os.Interrupt)\n\n// Create server\ns, _ := astisrt.NewServer(astisrt.ServerOptions{\n    // Provide options that will be passed to accepted connections\n    ConnectionOptions: []astisrt.ConnectionOption{\n        astisrt.WithLatency(300),\n        astisrt.WithTranstype(astisrt.TranstypeLive),\n    },\n\n    // Specify how an incoming connection should be handled before being accepted\n    // When false is returned, the connection is rejected.\n    OnBeforeAccept: func(c *astisrt.Connection, version int, streamID string) bool {\n        // Check stream id\n        if streamID != \"test\" {\n            // Set reject reason\n            c.SetPredefinedRejectReason(http.StatusNotFound)\n            return false\n        }\n\n        // Update passphrase\n        c.Options().SetPassphrase(\"passphrase\")\n\n        // Add stream id to context\n        *c = *c.WithContext(context.WithValue(c.Context(), ctxKeyStreamID, streamID))\n        return true\n    },\n\n    // Similar to http.Handler behavior, specify how a connection\n    // will be handled once accepted\n    Handler: astisrt.ServerHandlerFunc(func(c *astisrt.Connection) {\n        // Get stream id from context\n        if v := c.Context().Value(ctxKeyStreamID); v != nil {\n            log.Printf(\"main: handling connection with stream id %s\\n\", v.(string))\n        }\n\n        // Loop\n        for {\n            // Read\n            b := make([]byte, 1500)\n            n, _ := c.Read(b)\n\n            // Log\n            log.Printf(\"main: read `%s`\\n\", b[:n])\n\n            // Get stats\n            s, _ := c.Stats(false, false)\n\n            // Log\n            log.Printf(\"main: %d total bytes received\\n\", s.ByteRecvTotal())\n        }\n    }),\n\n    // Addr the server should be listening to\n    Host: \"127.0.0.1\",\n    Port: 4000,\n})\ndefer s.Close()\n\n// Listen and serve in a goroutine\ndoneListenAndServe := make(chan error)\ngo func() { doneListenAndServe \u003c- s.ListenAndServe(1) }()\n\n// Wait for SIGTERM\n\u003c-doneSignal\n\n// Create shutdown context with a timeout to make sure it's cancelled if it takes too much time\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\n\n// Shutdown\ns.Shutdown(ctx)\n\n// Wait for listen and serve to be done\n\u003c-doneListenAndServe\n```\n\n### Client\n\n[Go to full example](examples/client/main.go)\n\n```go\n// Capture SIGTERM\ndoneSignal := make(chan os.Signal, 1)\nsignal.Notify(doneSignal, os.Interrupt)\n\n// Dial\ndoneWrite := make(chan err)\nc, _ := astisrt.Dial(astisrt.DialOptions{\n    // Provide options to the connection\n    ConnectionOptions: []astisrt.ConnectionOption{\n        astisrt.WithLatency(300),\n        astisrt.WithPassphrase(\"passphrase\"),\n        astisrt.WithStreamid(\"test\"),\n    },\n\n    // Callback when the connection is disconnected\n    OnDisconnect: func(c *astisrt.Connection, err error) { doneWrite \u003c- err },\n\n    // Addr that should be dialed\n    Host: \"127.0.0.1\",\n    Port: 4000,\n})\ndefer c.Close()\n\n// Write in a goroutine\ngo func() {\n    defer func() { close(doneWrite) }()\n\n    // Loop\n    r := bufio.NewReader(os.Stdin)\n    for {\n        // Read from stdin\n        t, _ := r.ReadString('\\n')\n\n        // Write to the server\n        c.Write([]byte(t))\n    }\n}()\n\n// Wait for either SIGTERM or write end\nselect {\ncase \u003c-doneSignal:\n    c.Close()\ncase err := \u003c-doneWrite:\n    log.Println(err)\n}\n\n// Make sure write is done\nselect {\ncase \u003c-doneWrite:\ndefault:\n}\n```\n\n### Socket\n\n#### Listen\n\n[Go to full example](examples/socket/listen/main.go)\n\n```go\n// Create socket\ns, _ := astisrt.NewSocket()\ndefer s.Close()\n\n// Set listen callback\ns.SetListenCallback(func(s *astisrt.Socket, version int, addr *net.UDPAddr, streamID string) bool {\n    // Check stream id\n    if streamID != \"test\" {\n        // Set reject reason\n        s.SetRejectReason(1404)\n        return false\n    }\n\n    // Update passphrase\n    s.Options().SetPassphrase(\"passphrase\")\n    return true\n})\n\n// Bind\ns.Bind(\"127.0.0.1\", 4000)\n\n// Listen\ns.Listen(1)\n\n// Accept\nas, _, _ := s.Accept()\n\n// Receive message\nb := make([]byte, 1500)\nn, _ := as.ReceiveMessage(b)\n\n// Log\nlog.Printf(\"main: received `%s`\\n\", b[:n])\n```\n\n#### Connect\n\n[Go to full example](examples/socket/listen/main.go)\n\n```go\n// Create socket\ns, _ := astisrt.NewSocket()\ndefer s.Close()\n\n// Set connect callback\ndoneConnect := make(chan error)\ns.SetConnectCallback(func(s *astisrt.Socket, addr *net.UDPAddr, token int, err error) {\n    doneConnect \u003c- err\n})\n\n// Set passphrase\ns.Options().SetPassphrase(\"passphrase\")\n\n// Set stream id\ns.Options().SetStreamid(\"test\")\n\n// Connect\ns.Connect(\"127.0.0.1\", 4000)\n\n// Send message\ns.SendMessage([]byte(\"this is a test message\"))\n\n// Give time to the message to be received\ntime.Sleep(500 * time.Millisecond)\n\n// Close socket\ns.Close()\n\n// Wait for disconnect\n\u003c-doneConnect\n```\n\n## Install `srtlib` from source\n\nYou can find the instructions to install `srtlib` [here](https://github.com/Haivision/srt/tree/master/docs/build).\n\nHowever if you don't feel like doing it manually you can use the following command:\n\n```sh\n$ make install-srt\n```\n\n`srtlib` will be built from source in a directory named `tmp` and located in you working directory.\n\nFor your GO code to pick up `srtlib` dependency automatically, you'll need to add the following environment variables:\n\n(don't forget to replace `{{ path to your working directory }}` with the absolute path to your working directory)\n\n```sh\nexport LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:{{ path to your working directory }}/tmp/v1.5.3/lib/\",\nexport CGO_LDFLAGS=\"-L{{ path to your working directory }}/tmp/v1.5.3/lib/\",\nexport CGO_CFLAGS=\"-I{{ path to your working directory }}/tmp/v1.5.3/include/\",\nexport PKG_CONFIG_PATH=\"{{ path to your working directory }}/tmp/v1.5.3/lib/pkgconfig\",\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasticode%2Fgo-astisrt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasticode%2Fgo-astisrt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasticode%2Fgo-astisrt/lists"}