Open negbie opened 4 years ago
Hello @negbie , what type of changes do you propose? Is it to allow gosip correctly work with otubound proxy?
Currently you use msg.Destination() as the socket address here: https://github.com/ghettovoice/gosip/blob/master/transport/layer.go#L248
This makes it hard to use an outbound address which is different than the domain address.
Maybe
func NewLayer( ip net.IP, dnsResolver *net.Resolver, msgMapper sip.MessageMapper, logger log.Logger, )
can be changed to take a new proxy argument?
With that the send method can be extended with some logic to check if proxy != "" and so on...
You are right, with current implementation it's hard to override.
I'm just thinking maybe replace first arg ip net.IP
with something like cfg LayerConfig
where LayerConfig:
type LayerConfig {
HostIP net.IP
ProxyAddr net.Addr
...
}
Yeah that would be a way. Another way would be to use functional options https://sagikazarmark.hu/blog/functional-options-on-steroids/
Add ProxyAddr net.Addr to the layer struct and add a Proxy function which will return func(*layer). Now you can change the layer constructor to something like
func NewLayer( ip net.IP, dnsResolver net.Resolver, msgMapper sip.MessageMapper, logger log.Logger, opts ...func(layer), )
This has the benefit that it wouldn't be a breaking change.
Functional options looks very promising, especially non breaking api.
Let stay with this solution: leave ip net.IP
as now because this is required option for transport layer, and implement proxy (any other future options) as functional options.
Do you make pull request?
@ghettovoice will do it asap.
Hello @negbie, I'm checking in to see if you had a chance to work on this feature.
In case you were not able to, could you please share any progress you made on this? I will be happy to take this forward.
+1, interested in this may have to jump in and try to help with this implementation
Hi @ghettovoice would you be interested in a outbound proxy setting? Maybe by changing the NewLayer function signature? But this would be a breaking change. If you are interested I can create a pr but first I want to discuss it with you.