Skip to content

Commit

Permalink
info/info-provider: publish valid IPv6 addresses
Browse files Browse the repository at this point in the history
An IPv6 address within a URL must be escaped by being placed in square
brackets; an IPv4 address and a hostname must not be so escaped.
Currently info-provider publishes door interfaces without any escaping,
which is broken for IPv6 addresses.

Rather than placing the logic for escaping IPv6 address in
info-provider, info service is updated to publish an additional metric
('url-name') which is the interface's name in a format suitable for
building a URL.

The info-provider is updated to use this metric.  For backwards
compatibility, if the 'url-name' metric is missing then the 'FQDN'
metric is used as a fall-back.

Target: master
Patch: https://rb.dcache.org/r/8108/
Acked-by: Gerd Behrmann
Request: 2.12
Request: 2.11
Request: 2.10
Requires-book: no
Requires-notes: yes

Conflicts:
	modules/dcache-info/src/main/java/org/dcache/services/info/gathers/loginbroker/LoginBrokerLsMsgHandler.java

Conflicts:
	modules/dcache-info/src/main/java/org/dcache/services/info/gathers/loginbroker/LoginBrokerLsMsgHandler.java
	skel/share/info-provider/glue-1.3-defn.xml
	skel/share/info-provider/glue-2.0-defn.xml
  • Loading branch information
paulmillar committed Apr 20, 2015
1 parent df0a450 commit 026bd03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import org.dcache.services.info.gathers.CellMessageHandlerSkel;
import org.dcache.services.info.gathers.MessageMetadataRepository;

import static com.google.common.net.InetAddresses.isInetAddress;
import static com.google.common.net.InetAddresses.toUriString;

/**
* Parse the reply messages from sending the LoginBroker CellMessages with "ls -binary".
* These replies are an array of LoginBrokerInfo objects.
Expand Down Expand Up @@ -164,7 +167,10 @@ private void addInterfaceInfo( StateUpdate update, StatePath parentPath, String

update.appendUpdate( pathToInterfaceBranch.newChild( "FQDN"), new StringStateValue( address.getCanonicalHostName(), lifetime));

update.appendUpdate( pathToInterfaceBranch.newChild( "address"), new StringStateValue( address.getHostAddress(), lifetime));
String hostName = address.getHostAddress();
update.appendUpdate( pathToInterfaceBranch.newChild( "address"), new StringStateValue(hostName, lifetime));
String urlName = isInetAddress(hostName) ? toUriString(address) : hostName;
update.appendUpdate( pathToInterfaceBranch.newChild("url-name"), new StringStateValue(urlName, lifetime));
update.appendUpdate( pathToInterfaceBranch.newChild( "address-type"),
new StringStateValue( (address instanceof Inet4Address) ? "IPv4" : (address instanceof Inet6Address) ? "IPv6" : "unknown", lifetime));

Expand Down
3 changes: 2 additions & 1 deletion skel/share/info-provider/glue-1.3-defn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,8 @@
have a public-accessible FQDN, if any interface does -->
<attr name="GlueSEAccessProtocolEndpoint">
<lookup path="d:protocol/d:metric[@name='family']"/>://<lookup
path="d:interfaces/d:interface[d:metric[@name='order']=1]/d:metric[@name='FQDN']"/>:<lookup
path="d:interfaces/d:interface[d:metric[@name='order']=1]/d:metric[@name='url-name']"><lookup
path="d:interfaces/d:interface[d:metric[@name='order']=1]/d:metric[@name='FQDN']"/></lookup>:<lookup
path="d:metric[@name='port']"/>
</attr>

Expand Down
3 changes: 2 additions & 1 deletion skel/share/info-provider/glue-2.0-defn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@
<map name="door-protocol-family-to-URL-Schema">
<lookup path="d:protocol/d:metric[@name='family']"/>
</map>://<lookup
path="d:interfaces/d:interface[d:metric[@name='order']=1]/d:metric[@name='FQDN']"/>:<lookup
path="d:interfaces/d:interface[d:metric[@name='order']=1]/d:metric[@name='url-name']"><lookup
path="d:interfaces/d:interface[d:metric[@name='order']=1]/d:metric[@name='FQDN']"/></lookup>:<lookup
path="d:metric[@name='port']"/>
</attr>

Expand Down

0 comments on commit 026bd03

Please sign in to comment.