RestComm / jain-sip

Disclaimer: This repository is a git-svn mirror of the project found at http://java.net/projects/jsip whose original repository is developed collaboratively by the Advanced Networking Technologies Division at the National Institute of Standards and Technology (NIST) - an agency of the United States Department of Commerce and by a community of individual and enterprise contributors. TeleStax, Inc. will perform some productization work, new features experimentation branches, etc for its TelScale jSIP product that doesn't concern the community from the main repository hence this git repository.
http://www.restcomm.com/
141 stars 151 forks source link

ipv6 parser error when parse [2000:da8:203:612:0:3:0:12%2] #131

Closed xhoaluu closed 7 years ago

xhoaluu commented 7 years ago

When I used ipv6 in sip-servlet: it said

xhoaluu [4:04 PM]
added a Plain Text snippet 16:02:32,086 INFO [org.mobicents.servlet.sip.catalina.SipProtocolHandler] (MSC service thread 1-4) Sip Connector started on ip address: 2000:da8:203:612:0:3:0:12%2, port 5082, transport ws, useStun false, stunAddress null, stunPort : -1, useStaticAddress: false, staticServerAddress null, staticServerPort -1 16:02:32,102 INFO [org.mobicents.servlet.sip.catalina.SipProtocolHandler] (MSC service thread 1-1) Sip Connector started on ip address: 2000:da8:203:612:0:3:0:12%2, port 5081, transport tls, useStun false, stunAddress null, stunPort : -1, useStaticAddress: false, staticServerAddress null, staticServerPort -1 16:02:32,146 INFO [org.mobicents.servlet.sip.catalina.SipProtocolHandler] (MSC service thread 1-4) Sip Connector started on ip address: 2000:da8:203:612:0:3:0:12%2, port 5083, transport wss, useStun false, stunAddress null, stunPort : -1, useStaticAddress: false, staticServerAddress null, staticServerPort -1 16:02:32,166 WARN [org.mobicents.ha.javax.sip.MultiNetworkLoadBalancerHeartBeatingServiceImpl] (MSC service thread 1-3) SMPP port not set in System properties 16:02:32,178 WARN [org.mobicents.ha.javax.sip.MultiNetworkLoadBalancerHeartBeatingServiceImpl] (MSC service thread 1-3) Secure SMPP port not set in System properties 16:02:32,178 INFO [org.mobicents.servlet.sip.message.SipFactoryImpl] (MSC service thread 1-3) Load Balancer to Use LoadBalancer:127.0.0.1:5066:-1:2000 16:02:32,179 INFO [org.mobicents.servlet.sip.catalina.SipProtocolHandler] (MSC service thread 1-3) Sip Connector started on ip address: 2000:da8:203:612:0:3:0:12%2, port 5080, transport tcp, useStun false, stunAddress null, stunPort : -1, useStaticAddress: false, staticServerAddress null, staticServerPort -1 Add Comment Collapse

xhoaluu [4:04 PM]
sip-servlet send his ip address: "2000:da8:203:612:0:3:0:12%2" to LB

[4:05]
there is a special key in ip address "%2", this is the cause that the LB cannot parse IP address:

xhoaluu [4:05 PM]
added a Plain Text snippet Caused by: java.text.ParseException: sip:[2000:da8:203:612:0:3:0:12%2]: Illegal Host name at gov.nist.javax.sip.address.AddressFactoryImpl.createSipURI(AddressFactoryImpl.java:173) at org.mobicents.tools.sip.balancer.SIPBalancerForwarder.forwardRequest(SIPBalancerForwarder.java:1326) ... 7 more Add Comment

xhoaluu [4:06 PM]
Also, this is the cause that LB cannot forward the message to Sip-servlet. Does anyone help me on this ? (edited)

jean.deruelle [4:17 PM]
@xhoaluu you can check in the #load-balancer channel

[4:17]
given it's a load balancer issue

[4:17]
ideally you could provide a patch for this as well

kostyantyn.nosach [4:34 PM]
@jean.deruelle I disagree that this LB issue, why we should patch incorrect address in LB?

jean.deruelle [4:39 PM]
@kostyantyn.nosach what makes you say that 2000:da8:203:612:0:3:0:12%2 is incorrect ?

kostyantyn.nosach [4:40 PM]
%2

[4:40]
what is it

xhoaluu [4:40 PM]
No it's correct

jean.deruelle [4:40 PM]
when I try on http://formvalidation.io/validators/ip/ FormValidation Validate an IP address - FormValidation FormValidation - The best jQuery validation plugin to validate form fields, support Bootstrap, Zurb Foundation, Pure, Semantic, UIKit frameworks

[4:40]
it says it's valid

[4:40]
or on https://www.helpsystems.com/intermapper/ipv6-test-address-validation helpsystems.com IPv6 Test & Address Validation | HelpSystems Free IPv6 test to help you diagnose connection problems & show your current IPv6 address. Enter an IPv6 address to validate if it's properly formatted.

xhoaluu [4:40 PM]
But I'm validate it with RFC definition of ipv6

xhoaluu [4:42 PM]
added a Plain Text snippet IPv6reference = "[" IPv6address "]" IPv6address = hexpart [ ":" IPv4address ] hexpart = hexseq / hexseq "::" [ hexseq ] / "::" [ hexseq ] hexseq = hex4 ( ":" hex4) hex4 = 14HEXDIG port = 1*DIGIT Add Comment Collapse

xhoaluu [4:43 PM]
there is no definetion for "% code iD" in ipv6 (edited)

[4:46]
So is it wrong when sip-servlets sends ipv6 in wrong RFC format to LB, that makes LB cannot parse it ?

kostyantyn.nosach [4:46 PM]
@jean as you can see sip stack does not accepts it Caused by: java.text.ParseException: sip:[2000:da8:203:612:0:3:0:12%2]: Illegal Host name at gov.nist.javax.sip.address.AddressFactoryImpl.createSipURI(AddressFactoryImpl.java:173)

[4:47]
so its not LB issue , but sip stack parser

[4:47]
if you want it to support such address form it should be patched there

jean.deruelle [4:47 PM]
@xhoaluu how was SIP Servlets able to start

[4:47]
if the address is incorrect ?

xhoaluu [4:48 PM]
it started normally when I used: ./standalone.sh -b [2000:da8:203:612:0:3:0:12]

[4:48]
I can make a call to sip-servlet on 2000:da8:203:612:0:3:0:12

kostyantyn.nosach [4:49 PM]
i found the definition for that address form.

[4:49]
its called Link-Local IPv6 address

jean.deruelle [4:49 PM]
@xhoaluu please investigate why SIP Servlets

[4:49]
prints Sip Connector started on ip address: 2000:da8:203:612:0:3:0:12%2

[4:49]
instead of

[4:49]
Sip Connector started on ip address: 2000:da8:203:612:0:3:0:12

[4:49]
if you used 2000:da8:203:612:0:3:0:12

xhoaluu commented 7 years ago

This attribute need to be set in system gov.nist.core.STRIP_ADDR_SCOPES=true to accept IPv6 scope-id -Dgov.nist.core.STRIP_ADDR_SCOPES=true need to be used from system starting to make jain-sip support IPV6 scope-id

xhoaluu commented 7 years ago

Close the ticket, Jain-sip has already support parser for scope zone in IPv6.