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

feat: send wol packet from specific network interface #42

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 6 additions & 3 deletions devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
{
"name": "Server",
"mac": "34:E6:D7:33:12:71",
"ip": "192.168.1.255:9"
"ip": "192.168.1.255:9",
"interface": ""
},
{
"name": "NAS",
"mac": "28:C6:8E:36:DC:38",
"ip": "192.168.1.255:9"
"ip": "192.168.1.255:9",
"interface": ""
},
{
"name": "Laptop",
"mac": "18:1D:EA:70:A0:21",
"ip": "192.168.1.255:9"
"ip": "192.168.1.255:9",
"interface": ""
}
]
}
4 changes: 2 additions & 2 deletions rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func wakeUpWithDeviceName(w http.ResponseWriter, r *http.Request) {
if c.Name == deviceName {

// We found the Devicename
if err := SendMagicPacket(c.Mac, c.BroadcastIP, ""); err != nil {
if err := SendMagicPacket(c.Mac, c.BroadcastIP, c.Interface); err != nil {
// We got an internal Error on SendMagicPacket
w.WriteHeader(http.StatusInternalServerError)
result.Success = false
Expand All @@ -43,7 +43,7 @@ func wakeUpWithDeviceName(w http.ResponseWriter, r *http.Request) {
} else {
// Horray we send the WOL Packet succesfully
result.Success = true
result.Message = fmt.Sprintf("Sent magic packet to device '%s' with MAC '%s' on Broadcast IP '%s'.", c.Name, c.Mac, c.BroadcastIP)
result.Message = fmt.Sprintf("Sent magic packet to device '%s' with MAC '%s' on Broadcast IP '%s' with interface '%s'.", c.Name, c.Mac, c.BroadcastIP, c.Interface)
result.ErrorObject = nil
}
}
Expand Down
14 changes: 14 additions & 0 deletions static/js/wolweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ function renderData() {
// editing: false
});

// Interface Name Column
gridFields.push({
name: "interface", title: "Interface",
type: "text",
width: null,
insertTemplate: function () {
var $result = jsGrid.fields.text.prototype.insertTemplate.call(this); // original input
// $result.attr("disabled", true).css("background", "lightgray").val(bCastIP);
$result.val("");
return $result;
},
// editing: false
});

// Wake-up Action Column
gridFields.push({
name: "command", title: "Action",
Expand Down
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Device struct {
Name string `json:"name"`
Mac string `json:"mac"`
BroadcastIP string `json:"ip"`
Interface string `json:"interface"`
}

// AppData is list of Computer objects defined in JSON config file
Expand Down