-
Notifications
You must be signed in to change notification settings - Fork 161
feat(node): add hostport capability and network setup #855
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,135 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "net" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/AliyunContainerService/terway/plugin/driver/utils" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/coreos/go-iptables/iptables" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/vishvananda/netlink" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Configure iptables and ip rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func configureNetworkRules() error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ctx := context.Background() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mark = 0x10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mask = 0x10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tableID = 100 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultInterface = "eth0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| comment = "terway-portmap" // Rule comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rulePrio = 600 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+23
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Configure iptables and ip rule | |
| func configureNetworkRules() error { | |
| ctx := context.Background() | |
| var ( | |
| mark = 0x10 | |
| mask = 0x10 | |
| tableID = 100 | |
| defaultInterface = "eth0" | |
| comment = "terway-portmap" // Rule comment | |
| rulePrio = 600 | |
| const ( | |
| markDefault = 0x10 | |
| maskDefault = 0x10 | |
| tableIDDefault = 100 | |
| rulePriority = 600 | |
| ) | |
| // Configure iptables and ip rule | |
| func configureNetworkRules() error { | |
| ctx := context.Background() | |
| var ( | |
| mark = markDefault | |
| mask = maskDefault | |
| tableID = tableIDDefault | |
| defaultInterface = "eth0" | |
| comment = "terway-portmap" // Rule comment |
Copilot
AI
Jul 24, 2025
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.
Using fmt.Printf for logging in production code is not recommended. Consider using a proper logging framework or at least fmt.Fprintf to stderr for diagnostic messages.
Copilot
AI
Jul 24, 2025
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.
Using fmt.Printf for logging in production code is not recommended. Consider using a proper logging framework or at least fmt.Fprintf to stderr for diagnostic messages.
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.
Hardcoding 'eth0' as the default interface may not work in all environments. Consider making this configurable or dynamically detecting the primary network interface.