Code Monkey home page Code Monkey logo

go-sip-ua's People

Contributors

bean-du avatar brnt avatar chumvan avatar cloudwebrtc avatar danieldonoghue avatar dwagin avatar gaaf avatar ikingye avatar lq277012525 avatar pieerepi avatar renovate-bot avatar renovate[bot] avatar suapapa avatar userad avatar xcid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-sip-ua's Issues

Request: Create a simple client example with digest authentication

I'm having a heck of a time getting your examples/client/main.go file to successfully register with digest authentication. I did find one likely issue (#32) in the creation of the REGISTER message, but there's still something I'm missing. I wonder if instead of wading through SIP dumps and trying to debug the many layers involved, I could instead petition you to write an even simpler client example than is currently present. Something along the lines of:

ua := ua.NewUserAgent(&ua.UserAgentConfig{
	UserAgent: "Go Sip Client/1.0.0",
	SipStack:  stack,
}, logger)

ua.RegisterStateHandler = func(state account.RegisterState) {
	logger.Infof("RegisterStateHandler: user => %s, state => %v, expires => %v", state.Account.AuthInfo.AuthUser, state.StatusCode, state.Expiration)
}

uri, err := parser.ParseUri("sip:[email protected]:5061")
if err != nil {
	logger.Error(err)
}

profile := account.NewProfile(uri.Clone(), "goSIP",
	&account.AuthInfo{
		AuthUser: "100",
		Password: "blah",
		Realm:    "foo.bar.baz",
	},
	1800,
)

recipient, err := parser.ParseSipUri("sip:127.0.0.1:5060;transport=udp")
if err != nil {
	logger.Error(err)
}

go ua.SendRegister(profile, recipient, profile.Expires)

^^ This is my current attempt. The initial REGISTER message gets delivered just fine, and the registrar responds with a 401 as expected, along with the WWW-Authenticate parameters. However, that response just gets swallowed somewhere inside go-sip-ua or gosip.

P.S. Please feel free to point me at a mailing list or IRC channel if one of those would be more appropriate for this kind of request for help.

Thanks for all the time and effort you've obviously put into go-sip-ua. It's very promising. Good work!

关于handler条件竞争问题

	stack.OnRequest(sip.INVITE, ua.handleInvite)
	stack.OnRequest(sip.ACK, ua.handleACK)
	stack.OnRequest(sip.BYE, ua.handleBye)
	stack.OnRequest(sip.CANCEL, ua.handleCancel)

这里注册的handler中都操作了s.status = status 在收到response的时候可能会导致写入错误的状态

Multiple network interface does not work and others problems

I'm trying to use your pkg, and I find myself facing multiple worries.

First of all, in the endpoint.go file, the GetNetworkInfo function doesn't take the value Endpoint.ip

It makes errors when sending a call, or the caller can't find his interlocutor.
in the logs of my sip server, I have two different IPs, in LAN IP I have address 1 and in IP I have address 2.

Here is the function that works:

func (e EndPoint) GetNetworkInfo(protocol string) *transport.Target {
	//logger := e.Log() // Comment this because UNUSED 

	var target transport.Target

	target.Host = e.ip.String() //CHANGE HERE
	//the check do in the creation of the endpoint

	network := strings.ToUpper(protocol)
	if p, ok := e.listenPorts[network]; ok {
		target.Port = p
	} else {
		defPort := transport.DefaultPort(network)
		target.Port = &defPort
	}
	return &target
}

My second concern is the receptionand sending of audio, I can't find any example or any function allowing me to read or write the streams.
Thank you for making this library :D

I got a error,can someone help me?

�[0;34mconnection_key�[0m=udp:0.0.0.0:25066 �[0;34mdestination�[0m=[::]:25066 �[0;34mreceived_at�[0m=2022-01-11 16:00:16.5609191 +0800 CST m=+0.163700401 �[0;34mresponse_id�[0m=76b128b2-67a7-45ba-8641-9095365d8b56 �[0;34msource�[0m=110.42.252.203:25060 �[0;34mtransport�[0m=UDP �[0;34mtransport_layer_ptr�[0m=0xc00013e360
�[0;90m[2022-01-11 16:00:16.560]�[0m �[0;34mDEBUG�[0m�[0;36m transaction.Layer:�[0m handling SIP message �[0;34mconnection_key�[0m=udp:0.0.0.0:25066 �[0;34mdestination�[0m=[::]:25066 �[0;34mreceived_at�[0m=2022-01-11 16:00:16.5609191 +0800 CST m=+0.163700401 �[0;34mresponse_id�[0m=76b128b2-67a7-45ba-8641-9095365d8b56 �[0;34msource�[0m=110.42.252.203:25060 �[0;34mtransaction_layer_ptr�[0m=0xc00017a180 �[0;34mtransport�[0m=UDP
�[0;90m[2022-01-11 16:00:16.562]�[0m �[0;34mDEBUG�[0m�[0;36m transaction.ClientTx:�[0m act_non_invite_final �[0;34mdestination�[0m=110.42.252.203:25060 �[0;34mrequest_id�[0m=b649e7fe-4ddf-4c72-9440-8572fec51ed1 �[0;34msource�[0m=192.168.132.1:25066 �[0;34mtransaction_key�[0m=z9hG4bK.eq7WJVd0LmgSOtaIJeD7vdjNU17bV57k__REGISTER �[0;34mtransaction_layer_ptr�[0m=0xc00017a180 �[0;34mtransaction_ptr�[0m=0xc0001a2a20 �[0;34mtransport�[0m=UDP
panic: interface conversion: *sip.response is not sip.Request: missing method IsInvite

goroutine 36 [running]:
github.com/cloudwebrtc/go-sip-ua/pkg/ua.(*UserAgent).RequestWithContext.func2(0xc000088a00, 0xc00008cd80, 0x106db58, 0xc000328300, 0xc000194000)
D:/work_code/go-test/go-sip-ua-master/pkg/ua/ua.go:530 +0x7ce
github.com/cloudwebrtc/go-sip-ua/pkg/ua.(*UserAgent).RequestWithContext(0xc00032c050, 0x106db58, 0xc000328300, 0x10727b8, 0xc0003540b0, 0x1068500, 0xc000326080, 0x1, 0x2, 0x0, ...)
D:/work_code/go-test/go-sip-ua-master/pkg/ua/ua.go:553 +0x33f
github.com/cloudwebrtc/go-sip-ua/pkg/ua.(*UserAgent).RequestWithContext.func1(0x106db58, 0xc000328300, 0xc000194000, 0xc0003024c0, 0xc00030e600, 0x230a67a91d8, 0xc000323b00, 0xc00030e5a0, 0xc00030e540, 0x1, ...)
D:/work_code/go-test/go-sip-ua-master/pkg/ua/ua.go:471 +0x819
created by github.com/cloudwebrtc/go-sip-ua/pkg/ua.(*UserAgent).RequestWithContext
D:/work_code/go-test/go-sip-ua-master/pkg/ua/ua.go:379 +0x2b1
exit status 2
PS D:\work_code\go-test\go-sip-ua-master\examples\register>

<nil> Route headers added to request

Outgoing in-dialog requests fail because a Route header gets added if there are no Record-Route headers in the dialog-creating response.

This regression is introduced by #77

a way to get rtp stream ?

Hello,
I wanted to try your library but I never managed to get the audio streams back.
More concretely, I use freeswitch like ipbx, I can connect myself, receive the call event, pick up the call, as in the example, and then I don't know what to do.
When I try to read or write to the ports present in the SDP, with gstreamer, I have the impression that there are already reads or writes on these RTP streams.
Is there an ontrack function like in the pion/webrtc library?

注册问题

image
这是注册的示例代码,不太明白的是,一个账号为什么要反复填三个地方,有什么特定含义吗?

Q: idea for Google dialogflow phone gateway

Hi there,
First of all, I appreciate your contributions for Golang SIP frameworks.

I am looking for any idea to experiment a kind of Google dialogflow phone gateway with go-sip-ua package.
It will be a gateway, middleman in between ip-pbx and dialogflow for a conversational AI service.

Initially, I had considered some other options, but that could be tightly coupling with a pbx specific features.

  • Asterisk & UnirMRCP modules -> UniMRCP dialogflow plugin -> Google dialogflow
  • Asterisk & Stasis dialplan -> ARI app & ExternalMedia or AudioSocket + dialogflow interface -> Google dialogflow

How do you think for using go-sip-ua package for the gateway ?

I think that examples/client/main.go could be an example code as an starting point,
and considering to tweak the below code for injecting bidirectional streaming to/from dialogflow instead of rtp echoing.

func createUdp() *rtp.RtpUDPStream {
	udp = rtp.NewRtpUDPStream("127.0.0.1", rtp.DefaultPortMin, rtp.DefaultPortMax, func(data []byte, raddr net.Addr) {
		logger.Infof("Rtp recevied: %v, laddr %s : raddr %s", len(data), udp.LocalAddr().String(), raddr)
		dest, _ := net.ResolveUDPAddr(raddr.Network(), raddr.String())
		logger.Infof("Echo rtp to %v", raddr)
		udp.Send(data, dest)       // => tweak part
	})

	go udp.Read()

	return udp
}

Does this a possible approach, or not?
Any idea or guide for this trial ?

Thanks in advance.

Make log level configurable

Currently, log levels of SIP stack, transport and transaction layers are set to debug.
There is a way to change SIP stack log level but there is no way to change log level of transport and transaction layers.
Please, make it possible to configure it. It may also make sense to set log level to info by default.

WSS -> UDP B2BUA : "TCP not supported"

Hi,

I have been reviewing your B2BUA example in an effort to use it to accept calls over WSS & TLS and start a new "B leg" over UDP to another SIP server. So far I have been successfully able to accept calls over UDP and start a new UDP "B leg", but when I use WSS I get a cryptic error:

[2021-06-07 11:26:59.725] ERROR UserAgent: INVITE: Request [INVITE] failed, err => transport.UnsupportedProtocolError: protocol TCP is not supported

Is this something you have seen before?

As you can see from the code snippet below, my handler is quite similar to your handler in the b2bua example with only a few modifications.

I realise that error is coming from the ghettovoice/gosip library, so I will be opening an issue there also.

More detailed logs

In JSON logs below see field sipURI which is the newly constructed SIP URI for the B-leg.

connection_key=wss:<public-ip>:37916 destination=<public-ip>:37916 protocol_ptr=0xc00020c000 received_at=2021-06-07 11:26:59.723770792 +0000 UTC m=+66.491320370 request_id=b90ee9e6-d551-4225-9e0c-5ae80c0cf5b8 response_id=b90ee9e6-d551-4225-9e0c-5ae80c0cf5b8 source=10.89.5.252:5443 transaction_key=z9hG4bK7616340__0rkf2tfldjrh.invalid__443__INVITE transaction_ptr=0xc0000fa9a0 transport=WSS transport_layer_ptr=0xc000208000
{"level":"debug","version":"v0.0.0-dev","sipURI":"sip:<to-user>@<b-leg-domain>;lang=fr;transport=udp","time":"2021-06-07T11:26:59Z","caller":"/app/cuppa.go:93"}
{"level":"debug","version":"v0.0.0-dev","called":"sip:<to-user>@<A-leg-domain>;lang=fr","time":"2021-06-07T11:26:59Z","caller":"/app/cuppa.go:94"}
[2021-06-07 11:26:59.725] DEBUG transaction.Layer: client transaction created destination= request_id=4e07eea6-a680-437f-bb3a-27e533ad0bdb source= transaction_key=z9hG4bK.qTo7TdnZhwBwoMzVC2FnWJh58AYslaaP__INVITE transaction_layer_ptr=0xc000078100 transaction_ptr=0xc00031b440 transport=
[2021-06-07 11:26:59.725] DEBUG transaction.ClientTx: initialising INVITE transaction FSM destination= request_id=4e07eea6-a680-437f-bb3a-27e533ad0bdb source= transaction_key=z9hG4bK.qTo7TdnZhwBwoMzVC2FnWJh58AYslaaP__INVITE transaction_layer_ptr=0xc000078100 transaction_ptr=0xc00031b440 transport=
[2021-06-07 11:26:59.725] DEBUG transaction.ClientTx: act_trans_err destination= request_id=4e07eea6-a680-437f-bb3a-27e533ad0bdb source= transaction_key=z9hG4bK.qTo7TdnZhwBwoMzVC2FnWJh58AYslaaP__INVITE transaction_layer_ptr=0xc000078100 transaction_ptr=0xc00031b440 transport=
[2021-06-07 11:26:59.725] DEBUG transaction.ClientTx: act_delete destination= request_id=4e07eea6-a680-437f-bb3a-27e533ad0bdb source= transaction_key=z9hG4bK.qTo7TdnZhwBwoMzVC2FnWJh58AYslaaP__INVITE transaction_layer_ptr=0xc000078100 transaction_ptr=0xc00031b440 transport=
[2021-06-07 11:26:59.725] DEBUG transaction.ClientTx: transaction done destination= request_id=4e07eea6-a680-437f-bb3a-27e533ad0bdb source= transaction_key=z9hG4bK.qTo7TdnZhwBwoMzVC2FnWJh58AYslaaP__INVITE transaction_layer_ptr=0xc000078100 transaction_ptr=0xc00031b440 transport=
[2021-06-07 11:26:59.725] ERROR UserAgent: INVITE: Request [INVITE] failed, err => transport.UnsupportedProtocolError: protocol TCP is not supported
{"level":"warn","version":"v0.0.0-dev","call-id":"vun32hm9s7gr6ht1l6b8","time":"2021-06-07T11:26:59Z","caller":"/app/cuppa.go:99","message":"B-leg session err transport.UnsupportedProtocolError: protocol TCP is not supported"}
`session.InviteReceived` handling from `ua.InviteStateHandler`
to, _ := (*req).To()
from, _ := (*req).From()
caller := from.Address
called := to.Address

log.Debug().
	Str("to", to.String()).
	Interface("toParams", to.Params.Items()).
	Interface("to.URIParams", called.UriParams().Items()).
	Send() // DEBUG

// Check to see if we want to block this request.
if !checkRequest(caller, called) {
	return
}

doInvite := func(nextHop *registry.Server) int {
	displayName := ""
	if from.DisplayName != nil {
		displayName = from.DisplayName.String()
	}

	profile := account.NewProfile(caller, displayName, nil, 0, stack)

	// Build a string of the params attached to the incoming request.
	// With the exception of the transport parameter.
	clonedUriParams := to.Address.UriParams().Clone()
	//clonedUriParams.Remove("transport") // TODO REVIEW Do we need this?
	clonedUriParams.Add("transport", sip.String{"udp"})

	sipUri := fmt.Sprintf("sip:%s@%s", called.User().String(), nextHop.PrivateIP)
	recipient, errParse := parser.ParseSipUri(sipUri)
	if errParse != nil {
		log.Err(errParse).Send()
		return 500
	}
	recipient.SetUriParams(clonedUriParams)

	log.Debug().Str("sipURI", recipient.String()).Str("clonedUriParams", clonedUriParams.String()).Send() // DEBUG
	log.Debug().Str("called", called.String()).Send() // DEBUG

	offer := sess.RemoteSdp()
	newLeg, err := ua.Invite(profile, called, recipient, &offer)
	if err != nil {
		log.Warn().Str("call-id", (*req).GetHeaders("Call-ID")[0].Value()).Msgf("B-leg session err %s", err)
		return 500
	}

	c.addCall(sess.CallID().Value(), sess, newLeg)
	return 200
}

// Get nextHop from registry
nextHop, ok := c.registry.Get(config.GetString("nextHop"))
if nextHop != nil && ok {
	sess.Provisional(100, "Trying")
	status := doInvite(nextHop.(*registry.Server))
	switch status {
	case 200:
		// If our doInvite func was a success then return here
		return
	case 500:
		sess.Reject(500, "server error")
		return
	}
}
sess.Reject(404, "Not found")

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Add "rport" in via to support NAT.

Problem:
Can not connenct to SIP server when client behind a NAT network.

Request Log:

REGISTER sip:[email protected]:7060 SIP/2.0

Via: SIP/2.0/UDP 192.168.1.187:50066;branch=z9hG4bK.iJM9FQ5m5ZRW0ZJZTAvNGlTyN9JPA6Nl
......

What's expected:

REGISTER sip:[email protected]:7060 SIP/2.0

Via: SIP/2.0/UDP 192.168.1.187:50066;rport;branch=z9hG4bK.iJM9FQ5m5ZRW0ZJZTAvNGlTyN9JPA6Nl
......

Solution:
Add an additional "rport" parameter in "Via" when request is prepared. (RFC3581)
I submitted a PR draft at PR 98. This PR only checks the functionality, not the configuration, which may need to be added.

You've been busy!

Nice! Was just looking for something like this to create a SIP honeypot.

Client example-the example couldn't send voice to other UAC

Hi I have tested the client example ,and it can register to UAS, and can establish a session with other UAC, but the partner could't receive rtp stream, only receive echos as following

[2022-08-11 23:53:45.240] DEBUG Media: Send to 192.168.2.94:7076, length 172
[2022-08-11 23:53:45.258] INFO Client: Rtp recevied: 172, laddr 192.168.2.60:36191 : raddr 192.168.2.94:7076
[2022-08-11 23:53:45.258] INFO Client: Echo rtp to 192.168.2.94:7076

Why? I'm a freshman in SIP protocal.

register example - Request Timeout

Hi,
I am trying to implement a simple Registra to store IP of the two SIP device, starting with the examples/register. However, the program failed to make SIP REGISTER and kept showing Request Timeout error as can be seen from the screenshot below:

Screen Shot 2022-08-05 at 9 19 21

Initially I ran the code in the mac M1 and then tried it again with the ubuntu 20.04 virtual machine. Neither of them worked.
I haven't edited the code yet, just cloning and running via go run ./exmples/register/main -c.

package main

import (
	"os"
	"os/signal"
	"syscall"
	"time"

	"github.com/cloudwebrtc/go-sip-ua/pkg/account"
	"github.com/cloudwebrtc/go-sip-ua/pkg/media/rtp"
	"github.com/cloudwebrtc/go-sip-ua/pkg/stack"
	"github.com/cloudwebrtc/go-sip-ua/pkg/ua"
	"github.com/cloudwebrtc/go-sip-ua/pkg/utils"
	"github.com/ghettovoice/gosip/log"
	"github.com/ghettovoice/gosip/sip/parser"
)

var (
	logger log.Logger
	udp    *rtp.RtpUDPStream
)

func init() {
	logger = utils.NewLogrusLogger(log.DebugLevel, "Register", nil)
}

func main() {

	stop := make(chan os.Signal, 1)
	signal.Notify(stop, syscall.SIGTERM, syscall.SIGINT)
	stack := stack.NewSipStack(&stack.SipStackConfig{
		UserAgent:  "Go Sip Client/example-register",
		Extensions: []string{"replaces", "outbound"},
		Dns:        "8.8.8.8"})

	if err := stack.Listen("udp", "0.0.0.0:5066"); err != nil {
		logger.Panic(err)
	}

	ua := ua.NewUserAgent(&ua.UserAgentConfig{
		SipStack: stack,
	})

	ua.RegisterStateHandler = func(state account.RegisterState) {
		logger.Infof("RegisterStateHandler: user => %s, state => %v, expires => %v, reason => %v", state.Account.AuthInfo.AuthUser, state.StatusCode, state.Expiration, state.Reason)
	}

	uri, err := parser.ParseUri("sip:[email protected]") // this acts as an identifier, not connection info
	if err != nil {
		logger.Error(err)
	}

	profile := account.NewProfile(uri.Clone(), "goSIP",
		&account.AuthInfo{
			AuthUser: "100",
			Password: "100",
			Realm:    "b2bua",
		},
		1800,
		stack,
	)

	recipient, err := parser.ParseSipUri("sip:[email protected];transport=udp") // this is the remote address
	if err != nil {
		logger.Error(err)
	}

	register, err := ua.SendRegister(profile, recipient, profile.Expires, nil)
	if err != nil {
		logger.Error(err)
	}

	time.Sleep(time.Second * 5)

	register.SendRegister(0)

	time.Sleep(time.Second * 5)

	register.SendRegister(300)

	time.Sleep(time.Second * 5)

	register.SendRegister(0)

	<-stop

	ua.Shutdown()
}

I saw some issues mentioned by @brnt but this seems to be a different one. Let me know if I could provide more info
Thank you for your help.

[邀请]字节跳动Flutter PC技术经理岗位

我也是武汉人,目前就职于北京字节跳动Flutter PC组

我们目前已经在推进Flutter PC的应用了,比如:
https://github.com/woodemi/Flutter-RTM-Desktop
https://github.com/woodemi/Flutter-SDK-Desktop

每双周和Google同步一次进度,昨天还开会说了Windows打包编译问题,因为飞书已经开始用了

头条薪资绝对丰厚(这个想必有耳闻),北上广深杭、武汉都有分部,疫情期间都飞书远程办公,位置都不是问题

不知道您是否考虑来指导下我们组呢 :)

微信:wk2311007
邮箱:[email protected]

Example UA sends SIP BYE

Hi,
Could anyone share how to send a SIP BYE to a SIP Server using this package? From the example and ua in the pkg, I can only see the Invite and Register implemented.
Thanks for your help.

Persistent CallID

I tried the register example from this repo - and noticed that every time the app sends a REGISTER it's using a different sip call-id, is it possible to keep it persistent?

Getting PANIC error on startup following "README" instructions about TLS not supported

Hey gang -- just trying out this example on my Mac OS -- and when I run the example for b2bua I get this PANIC error ..

`go run examples/b2bua/main.go -c
... Lots of Download messages ...
Start pprof on :6655
[2020-09-11 09:37:42.610] INFO transport.Layer: begin serve protocols sip_server_ptr=0xc0002240b0 transport_layer_ptr=0xc000254120
[2020-09-11 09:37:42.610] INFO transport.Protocol: begin listening on UDP 0.0.0.0:5060 protocol_ptr=0xc00020c280 sip_server_ptr=0xc0002240b0 transport_layer_ptr=0xc000254120
[2020-09-11 09:37:42.611] INFO transport.Protocol: begin listening on TCP 0.0.0.0:5060 protocol_ptr=0xc00007e730 sip_server_ptr=0xc0002240b0 transport_layer_ptr=0xc000254120
[2020-09-11 09:37:42.611] PANIC B2BUA: transport.UnsupportedProtocolError: protocol TLS is not supported
panic: (*logrus.Entry) 0xc000194a80

goroutine 1 [running]:
github.com/sirupsen/logrus.Entry.log(0xc000216850, 0xc00019a9c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/sjm/go/pkg/mod/github.com/sirupsen/[email protected]/entry.go:259 +0x345
github.com/sirupsen/logrus.(*Entry).Log(0xc000194a10, 0x0, 0xc000069660, 0x1, 0x1)
/Users/sjm/go/pkg/mod/github.com/sirupsen/[email protected]/entry.go:287 +0xf0
github.com/sirupsen/logrus.(*Entry).Panic(0xc000194a10, 0xc000069660, 0x1, 0x1)
/Users/sjm/go/pkg/mod/github.com/sirupsen/[email protected]/entry.go:325 +0x55
github.com/ghettovoice/gosip/log.(*LogrusLogger).Panic(0xc000202e70, 0xc000069660, 0x1, 0x1)
/Users/sjm/go/pkg/mod/github.com/ghettovoice/[email protected]/log/logrus.go:89 +0x57
github.com/cloudwebrtc/go-sip-ua/pkg/b2bua.NewB2BUA(0xc000000000)
/Users/sjm/play/b2bua/go-sip-ua/pkg/b2bua/b2bua.go:64 +0x676
main.main()
/Users/sjm/play/b2bua/go-sip-ua/examples/b2bua/main.go:98 +0x215
exit status 2`

I've done some basic Googling but haven't really hit on what the issue is -- seems pretty fundamental..

Thanks for any help!

如何发送信息

问下,建立连接后, 如何发送信息, 如: 按键信息, 语言信息?

how to disable verify server certificate

thanks for the open source library.

i want to turn off tls certificate verification, I tried to trace in the code, but no luck and didn't find the correct configuration item.

SendRegister() places From URI in Contact field

On line 184 of pkg/ua/ua.go, the To field is currently being set to profile.URI (same as the From field), but it should probably be changed to:

to := &sip.Address{
    Uri: &recipient,
}

or

to := &sip.Address{
    Uri: recipient.Clone(),
}

I'd create a pull request, but I'm unsure of how you'd prefer to structure it (with or without Clone()).

Dialogs/sessions completely broken because of wrong sessionkey

UA builds a session key from the Call-ID and the branch-id. This is not how a dialog id should be constructed. The branch-id is transaction-specific and has no place in a session (dialog).

This makes all in-dialog requests to fail to match the session.

As a dialog is identified solely by Call-ID, local-tag and remote-tag (rfc3261) please use these to build the session key. This of course requires knowledge of the remote tag, which is only available after a response >100 is received. In absence of forking support, an intermediary solution would be to only use Call-ID and local tag for the dialog id.

The breakage seems to have been introduced by #73.

read和close可能发生条件竞争

func (r *RtpUDPStream) Read() {

	if r.stop {
			r.Log().Infof("Terminate: stop rtp conn now!")
			return
		}
		n, raddr, err := r.conn.ReadFrom(buf)
		if err != nil {
			r.Log().Warnf("RTP Conn [%v] refused, err: %v, stop now!", raddr, err)
			return
		}

如果先执行了if判断后,udp被close,那么后面代码将会继续执行。

send ACK request failed: transport.UnsupportedProtocolError: protocol TLS is not supported

Hey there,

I am trying to connect to my Webex meeting using the client example.
The library sends an "INVITE" request to the server. The server responses with "Trying", "Ringing", and finally "OK". Here is the "OK" response:

Via: SIP/2.0/TCP 192.168.0.115:5080;branch=z9hG4bK.vWHLeFU2E7W76whrkBCh9Q5MiyNfRd5F
Record-Route: <sip:l2sip-aore-01.wbx2.com:5062;transport=tls;lr>
Record-Route: <sip:[email protected]:5060;transport=tcp;lr;bypassvcs=true>
To: <sip:[email protected]>;tag=77899554
From: "goSIP/example-client" <sip:[email protected];transport=tcp>;tag=FWwqwkFA
Contact: <sip:[email protected]:5062;transport=tls>;isfocus
Call-ID: 5IyihuOqPiUgXGHx9452tJ3HN5qBqV3u
CSeq: 1 INVITE
Content-Length: 287
Session-ID: 340af0dbc2569b63b00c4706ce7a35d0;remote=ef15ce9d3dca30c6ae3aefd3e42d66de
Locus: 184d96d5-757a-3279-b289-16d139e9e35c
Locus-SessionId: 340af0db-c256-9b63-b00c-4706ce7a35d0
Locus-Type: MEETING
WebexMeetingNumber: XXXXXXXX
User-Agent: Cisco-L2SIP
Accept: application/sdp
Allow: INVITE, ACK, CANCEL, BYE, REFER, INFO, OPTIONS, NOTIFY, SUBSCRIBE
Allow-Events: kpml
Supported: replaces
Content-Type: application/sdp

Which contains Record-Route header field. After receiving this message, the library wants to respond with an "ACK" message. Here is the error:

[2021-06-08 12:02:01.568] ERROR SipStack: send ACK request failed: transport.UnsupportedProtocolError: protocol TLS is not supported ack_request=sip.Request<recipient=sip:[email protected]:5062;transport=tls transaction_key=z9hG4bK.vWHLeFU2E7W76whrkBCh9Q5MiyNfRd5F__INVITE sent_at=2021-06-08 12:02:01.568402932 +0430 +0430 m=+3.146215901 request_id=2121ffc5-c694-48e2-8880-783458cae0c9 transaction_ptr=0xc000179d40 method=ACK invite_request_id=d2f5a7c3-2871-48a2-b1f9-c658d05d7e07 invite_response_id=255ef8b0-d4ab-413d-9b42-c05a4ee863bf sequence=1> invite_request=sip.Request<method=INVITE recipient=sip:[email protected];transport=tcp sequence=1 request_id=d2f5a7c3-2871-48a2-b1f9-c658d05d7e07 transaction_ptr=0xc000179d40 transaction_key=z9hG4bK.vWHLeFU2E7W76whrkBCh9Q5MiyNfRd5F__INVITE> invite_response=sip.Response<reason=OK method=INVITE sequence=1 response_id=255ef8b0-d4ab-413d-9b42-c05a4ee863bf connection_key=tcp:209.197.207.55:5060 received_at=2021-06-08 12:02:01.567166135 +0430 +0430 m=+3.144979233 request_id=d2f5a7c3-2871-48a2-b1f9-c658d05d7e07 status=200>

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.


  • Check this box to trigger a request for Renovate to run again on this repository

Could this library support method Message?

Hi, i have test your lib,and find it hav't support method Message,But some protocal like GB28181 use Message method,could you improve the lib to support method Message?

ua.go incorrectly assumes that a received invite is a reinvite.

in ua.go, handleInvite(), it is assumed that if a transaction is found, the incoming request must be a reinvite. this is not necessarily correct..

  • a reinvite is determined by having a "to" tag and cannot happen outside of an established dialog.
  • a dialog is determined based on the call-id and the branch id (from the Via header), not just the call-id.

if an INVITE is received and it has a "t"o tag, it is a reinivte. if there is no transaction found for that request, a 481 "transaction does not exist" response should be sent. However, if the transaction is found, this should be considered a reinvite.

if an INVITE is received that has no to tag, it is not part of a sip dialog and, as such, cannot be a reinvite. it should be considered a new invite (or a retransmission due to lack of timely response) unless a matching transaction, for the branch id and call-id combination already exists. In which case, a 482 loop detected response (or similar) should be sent.

in all other cases, the INVITE should be considered a new request.

Wrong contact in case of multiple interfaces

func (s SipStack) GetNetworkInfo(protocol string) *transport.Target

Just uses util.ResolveSelfIP() for the contact address. I would suggest to change it into:

	var target transport.Target
	if s.host != "" {
		target.Host = s.host
	} else if v, err := util.ResolveSelfIP(); err == nil {
		target.Host = v.String()
	} else {
		logger.Panicf("resolve host IP failed: %s", err)
	}

Contact header

Hello, thanks for this implementation.

Seems like the contact header returned is not the correct one.

Right now, we return:
sip:[email protected]>;tag=V52m0ANK

After reverse-engineering a real SIP Client/Server, seems like it's better to return the local address like:

sip:[email protected];tag=any

I had issue with the first version, I never received the BYE call from the SIP Server. With the local, everything works again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.