SIP library for writing fast SIP services in GO
SIPGO is library for writing fast SIP services in GO language.
It comes with SIP stack (RFC 3261|RFC3581|RFC6026) optimized for fast parsing.
Libs on top of sipgo:
Tools developed on top:
Fetch lib with:
go get github.com/emiago/sipgo
If you like/use project currently and looking for support/sponsoring checkout Support section
You can follow on X/Twitter for more updates.
More on documentation you can find on Go doc
State of Torture Tests RFC4475 you can find on issue github.com/emiago/sipgo/issues/57 but NOTE: some strict validation things may be seperated from parsing or not built into library.
Also thanks to pion project sharing this example of using SIPgo with webrtc:
SIPgo was proven that can excel in performance compared to some other configured base proxy solutions.
As an example, you can find example/proxysip as simple version of statefull proxy. It is used for stress testing with sipp.
To find out more about performance check the latest results:
example/proxysip
Lib allows you to write easily sip servers, clients, stateful proxies, registrars or any sip routing. Writing in GO we are not limited to handle SIP requests/responses in many ways, or to integrate and scale with any external services (databases, caches...).
Using server or client handle for UA you can build incoming or outgoing requests.
…go client, _ := sipgo.NewClient(ua) // Creating client handle req := sip.NewRequest(sip.ACK, sip.Uri{User:"bob", Host: "example.com"}) // Send request and forget client.WriteRequest(req)
…go ua, _ := sipgo.NewUA() // Build user agent srv, _ := sipgo.NewServer(ua) // Creating server handle client, _ := sipgo.NewClient(ua) // Creating client handle
contactHDR := sip.ContactHeader{ Address: sip.Uri{User: "test", Host: "127.0.0.200", Port: 5088}, } dialogCli := sipgo.NewDialogClientCache(client, contactHDR)
// Attach Bye handling for dialog srv.OnBye(func(req *sip.Request, tx sip.ServerTransaction) { err := dialogCli.ReadBye(req, tx) //handle error })
// Create dialog session dialog, err := dialogCli.Invite(ctx, recipientURI, nil) defer dialog.Close() // Cleans up from dialog pool // Wait for answer err = dialog.WaitAnswer(ctx, AnswerOptions{}) // Check dialog response dialog.InviteResponse (SDP) and return ACK err = dialog.Ack(ctx) // Send BYE to terminate call err = dialog.Bye(ctx)
**UAS**:
```go
ua, _ := sipgo.NewUA() // Build user agent
srv, _ := sipgo.NewServer(ua) // Creating server handle
client, _ := sipgo.NewClient(ua) // Creating client handle
uasContact := sip.ContactHeader{
Address: sip.Uri{User: "test", Host: "127.0.0.200", Port: 5099},
}
dialogSrv := sipgo.NewDialogServerCache(client, uasContact)
srv.OnInvite(func(req *sip.Request, tx sip.ServerTransaction) {
dlg, err := dialogSrv.ReadInvite(req, tx)
if err != nil {
return err
}
defer dlg.Close() // Close for cleanup from cache
// handle error
dlg.Respond(sip.StatusTrying, "Trying", nil)
dlg.Respond(sip.StatusOK, "OK", nil)
// Instead Done also dlg.State() can be used for granular state checking
Call-ID: [email protected]
From: "sipp" ;tag=1SIPpTag001
To: "uac"
CSeq: 1 INVITE
Server: Asterisk PBX 18.16.0
Content-Length: 0If you find this project interesting for bigger support or consulting, you can contact me on mail
For bugs features pls create issue.
If you are interested using lib for your testing services then checkout article on how easy you can make calls and other
Library will be covered with more tests. Focus is more on benchmarking currently.
go test ./... This project was influenced by gosip, project by @ghetovoice, but started as new project to achieve best/better performance and to improve API. This unfortunately required many design changes, therefore this libraries are not compatible.
No open issues yet, or sync has not completed.