Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#439 HTTP_bind_by_NIC_interfacename #442

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

G-Ork
Copy link

@G-Ork G-Ork commented Jun 21, 2020

  • Delegate address resolving to an global service
  • Added service for RegEx matching on IPs
  • Added service for RegEx matching on interface names
  • Extend DocBook for jvm-agent config

- Delegate address resolving to an global service
- Added service for RegEx matching on IPs
- Added service for RegEx matching on interface names
- Extend DocBook for jvm-agent config
@rhuss
Copy link
Member

rhuss commented Jun 22, 2020

Thanks a lot for your contribution ! I have a busy week ahead but will reserve some time on Friday to work integrate the PR (and also think about what todo with Java 6 support)

have a nice week ...

Copy link
Member

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again, looks nice !

I have some suggestions, see below. Especially wrt to naming the variable I would fold everything into the already existing host config key.

* Optional wich isn't available in Java 6.
* @throws RuntimeException If the configuration is invalid.
*/
public AtomicReference<InetAddress> optain(Map<String, String> agentConfig) throws RuntimeException;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo (obtain instead of optain). But please rename to something like "extractAddress" or so (fits better to the existing naming scheme)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to declare that it throws a RuntimeException.

* Konstructor
*/
public DelegatingAddressConfigService() {
super();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No needed.

public DelegatingAddressConfigService() {
super();

this.services = Collections.unmodifiableList(Arrays.asList(new AddressConfigService[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to create an array, just use the varadic form of asList.

AtomicReference<InetAddress> ref = service.optain(agentConfig);

if ( null != ref) {
this.address = ref.get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should throw an error when no address could be detected (like before).

Btw, I wouldn't mind to inline the DelegatingAdressConfigService() here (i.e. iterate directly over the the various address resolvers), to skip one level of abstraction and also make clear that there is always a default value for the address. (i..e effectively ref can't be null, but that's not clear from the call)

</td>
<td>
<constant>localhost</constant>
</td>
</tr>
<tr>
<td><constant>ipmatch</constant></td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we could avoid to a new configuration key like nicmatch or ipmatch and fold everything into the existing host variable. This approach would have multiple advantages:

  • Multiple config-clashes would be avoided automatically
  • Don't blow up the already huge configuration surface

So my suggestion would be to introduce multiples prefix like nic: or ip: which then trigger the different modes. Maybe even better just a match: if from the value it could be determined whether its a mac or an IP (by the existence of a : in the value ?)

Wdyt ?

@G-Ork
Copy link
Author

G-Ork commented Jun 26, 2020

Hi thanks for the review and your feedback. I've stubled over many of the topics you suggested during the implementation.

I don't mind to consider your suggestion. It would be alot easier to reuse the existing key. A prefix would be the best workaround to extend the matching without conflict with the old style dots in ip matching and the RegEx dots in the alternative matching options.

Did you see a need for supporting to classify ipv4 or ipv6? For myself I decided it for the whole JVM. So I don't need a config key to only bind ipv4.

I would extend the documentation by a table with examples. This should be clearly to understand.

I try to change it next week.
I'm not allowed to code this weekend 😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants