8000 feat: add endpoint to get listening ports in agent by deansheather · Pull Request #4260 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: add endpoint to get listening ports in agent #4260

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

Merged
merged 13 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! Merge branch 'main' into dean/listening-ports
  • Loading branch information
deansheather committed Oct 6, 2022
commit b084277d37637e67bb99f406d9d0ba590123ecfe
8 changes: 6 additions & 2 deletions agent/ports_supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.ListeningPort,

ports := []codersdk.ListeningPort{}
for _, tab := range tabs {
if tab.LocalAddr.Port < uint16(codersdk.MinimumListeningPort) {
if tab.LocalAddr == nil || tab.LocalAddr.Port < uint16(codersdk.MinimumListeningPort) {
continue
}

procName := ""
if tab.Process != nil {
procName = tab.Process.Name
}
ports = append(ports, codersdk.ListeningPort{
ProcessName: tab.Process.Name,
ProcessName: procName,
Network: codersdk.ListeningPortNetworkTCP,
Port: tab.LocalAddr.Port,
})
Expand Down
4 changes: 2 additions & 2 deletions codersdk/agentconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ const (
)

type ListeningPort struct {
ProcessName string `json:"process_name"`
Network ListeningPortNetwork `json:"network"` // only "tcp" at the moment
ProcessName string `json:"process_name"` // may be empty
Network ListeningPortNetwork `json:"network"` // only "tcp" at the moment
Port uint16 `json:"port"`
}

Expand Down
3834
0