-
Notifications
You must be signed in to change notification settings - Fork 626
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
Allow forwarding of specified port ranges to all interfaces #114
Conversation
What about ports:
- guestPort: 443
hostIP: "0.0.0.0" # overrides the default value "127.0.0.1"
# default: hostPort: 443
# default: guestIP: "127.0.0.1" (implementation can be done later, but we have to reserve the field name now)
# default: proto: "tcp" (same as above)
- guestPortRange: [4000, 4999]
hostIP: "0.0.0.0" # overrides the default value "127.0.0.1"
# default: hostPortRange: [4000, 4999]
# default: guestIP: "127.0.0.1"
# default: proto: "tcp"
- guestPort: 80
hostPort: 8080 # overrides the default value 80
# default: hostIP: "127.0.0.1"
# default: guestIP: "127.0.0.1"
# default: proto: "tcp"
No, iptables inside the guest cannot be used, as the guest is unaware of the src IP. I assume #45 will not need a new YAML field. "Try |
Yes, much better and more flexible. I've updated the PR to match your samples. |
ad4434d
to
493a2d9
Compare
Sorry, did one more push to fix a trivial error in an error message: case port > 65535:
- return errors.Errorf("field `%s` must be < 65535", field)
+ return errors.Errorf("field `%s` must be < 65536", field) But now I'm really done... |
@AkihiroSuda I've been wondering how Even if the port is bound to I tried to make the logic deal with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see unit tests and/or integration tests, but tests can be added later
I guess the "guestIP" isn't going to be used in most cases. The field is only useful when an application inside VM calls |
I've been trying to create integration tests today, but can't make them work reliably because there is no way to flush the hostagent logs to disk. While looking into this I noticed that Anyways, will change the tests to shut down the instance, and analyze the logs afterwards. BTW, I noticed that virtually all the output from the hostagent except for status messages goes to stderr. If this is intentional, then I think it would make more sense to just have a single log stream for the hostagent. |
Implemented in commit
Stdout is guaranteed to be unmarshallable as JSON lines, but stderr is no, because imported libraries may print something to stderr without using logrus. So we have to maintain the two streams. |
Thanks! It turns out that I also mis-remembered that the guest-agent checks for port changes every second; it only checks every 3 seconds; so my strategic I see that the (Wild idea for some distant time in the future: make the polling adaptive: poll more frequently whenever a new process or container is being created, as ports are typically opened early in the lifetime of a server process. Back off later, and especially when running on battery. Not sure if it is worth it; maybe it is just related to me seeing a demo using eBPF/LSM hooks yesterday 😄 ).
Yes, but stdout seems to contain only 2 lines: {"time":"2021-07-21T00:09:03.305227-07:00","status":{"sshLocalPort":60020}}
{"time":"2021-07-21T00:09:25.48178-07:00","status":{"running":true,"sshLocalPort":60020}} I don't think they are important enough to require a separate JSON-unmarshallable file. Is there anything else written to it? Anyways, my argument was that all the tracing and logging should go into stdout as well, and only errors should be written to stderr. Or maybe I'm still confused about what each file is supposed to be used for. |
Either is fine to me, but I think we should clarify that the field is likely to be removed in future.
Yes, actually I was planning to replace ticks with eBPF retprobes for |
This allows to expose e.g. an ingress port outside of the local host while still forwarding other ports only to localhost. Forwarding to all interfaces is curiously not limited to unprivileged ports. Signed-off-by: Jan Dubois <[email protected]>
Signed-off-by: Jan Dubois <[email protected]>
f065520
to
6e71758
Compare
Use net.IP internally instead of strings, and implement even default block and forwarding rules via data instead of code. Signed-off-by: Jan Dubois <[email protected]>
6e71758
to
2e4d579
Compare
Signed-off-by: Jan Dubois <[email protected]>
Signed-off-by: Jan Dubois <[email protected]>
Signed-off-by: Jan Dubois <[email protected]>
2e4d579
to
24f9bdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This allows to expose e.g. an ingress port outside of the local host while still forwarding other ports only to localhost.
Example:
I'm not quite sure how this will interact with #45, but I think/hope it will be independent (the filtering of incoming connections would be done via
iptables
inside the guest?).I'm also not really happy about the
allInterfaces
key name, but couldn't come up with anything better.