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

Adding sockaddr namespace #271

Merged
merged 2 commits into from
Mar 4, 2018
Merged

Adding sockaddr namespace #271

merged 2 commits into from
Mar 4, 2018

Conversation

hairyhenderson
Copy link
Owner

@hairyhenderson hairyhenderson commented Mar 4, 2018

Fixes #145

Adds a pile of functions from the go-sockaddr package:

  • sockaddr.GetAllInterfaces
  • sockaddr.GetDefaultInterfaces
  • sockaddr.GetPrivateInterfaces
  • sockaddr.GetPublicInterfaces
  • sockaddr.Sort
  • sockaddr.Exclude
  • sockaddr.Include
  • sockaddr.Attr
  • sockaddr.Join
  • sockaddr.Limit
  • sockaddr.Offset
  • sockaddr.Unique
  • sockaddr.Math
  • sockaddr.GetPrivateIP
  • sockaddr.GetPrivateIPs
  • sockaddr.GetPublicIP
  • sockaddr.GetPublicIPs
  • sockaddr.GetInterfaceIP
  • sockaddr.GetInterfaceIPs

I tried to closely match the function names that are exported in github.com/hashicorp/go-sockaddr/template, though couldn't directly import the FuncMaps defined therein, because I'd like these to be namespaced.

/cc @jen20 @sean-

@hairyhenderson hairyhenderson self-assigned this Mar 4, 2018
@hairyhenderson hairyhenderson force-pushed the add-sockaddr-funcs-145 branch 2 times, most recently from 88675f5 to 97cd199 Compare March 4, 2018 01:09
Copy link

@sean- sean- left a comment

Choose a reason for hiding this comment

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

I'm looking forward to being able to use this.

sockaddrNSInit sync.Once
)

// SockaddrNS - the crypto namespace
Copy link

Choose a reason for hiding this comment

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

Cargo-culted crypto?

Copy link
Owner Author

Choose a reason for hiding this comment

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

😂 good old copy-pasta 🍝

{{ . | sockaddr.Attr "address" }}
{{end}}`)
result.Assert(c, icmd.Expected{ExitCode: 0, Out: "127.0.0.1"})
}
Copy link

Choose a reason for hiding this comment

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

I need to go back and write a helper function that's builtin to go-sockaddr that makes testing easier.

Copy link
Owner Author

Choose a reason for hiding this comment

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

the ability to inject some fake interface/address state to go-sockaddr would be useful for testing, but not entirely crucial...

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
@hairyhenderson hairyhenderson changed the title [WIP] Adding sockaddr namespace Adding sockaddr namespace Mar 4, 2018
@hairyhenderson hairyhenderson merged commit aa86bc7 into master Mar 4, 2018
@hairyhenderson hairyhenderson deleted the add-sockaddr-funcs-145 branch March 4, 2018 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add go-sockaddr functions
2 participants