Skip to content

Commit 2ed51f4

Browse files
authored
Merge pull request #42 from Revincx/main
feat: send wol packet from specific network interface
2 parents 13cdb99 + 19166ec commit 2ed51f4

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

devices.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
{
44
"name": "Server1",
55
"mac": "34:E6:D7:33:12:71",
6-
"ip": "192.168.1.255:9"
6+
"ip": "192.168.1.255:9",
7+
"interface": ""
78
},
89
{
910
"name": "NAS",
1011
"mac": "28:C6:8E:36:DC:38",
11-
"ip": "192.168.1.255:9"
12+
"ip": "192.168.1.255:9",
13+
"interface": ""
1214
},
1315
{
1416
"name": "Laptop2",
1517
"mac": "18:1D:EA:70:A0:21",
16-
"ip": "192.168.1.255:9"
18+
"ip": "192.168.1.255:9",
19+
"interface": ""
1720
}
1821
]
1922
}

rest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func wakeUpWithDeviceName(w http.ResponseWriter, r *http.Request) {
3434
if c.Name == deviceName {
3535

3636
// We found the Devicename
37-
if err := SendMagicPacket(c.Mac, c.BroadcastIP, ""); err != nil {
37+
if err := SendMagicPacket(c.Mac, c.BroadcastIP, c.Interface); err != nil {
3838
// We got an internal Error on SendMagicPacket
3939
w.WriteHeader(http.StatusInternalServerError)
4040
result.Success = false
@@ -43,7 +43,7 @@ func wakeUpWithDeviceName(w http.ResponseWriter, r *http.Request) {
4343
} else {
4444
// Horray we send the WOL Packet succesfully
4545
result.Success = true
46-
result.Message = fmt.Sprintf("Sent magic packet to device '%s' with MAC '%s' on Broadcast IP '%s'.", c.Name, c.Mac, c.BroadcastIP)
46+
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)
4747
result.ErrorObject = nil
4848
}
4949
}

static/js/wolweb.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ function renderData() {
110110
// editing: false
111111
});
112112

113+
// Interface Name Column
114+
gridFields.push({
115+
name: "interface", title: "Interface",
116+
type: "text",
117+
width: null,
118+
insertTemplate: function () {
119+
var $result = jsGrid.fields.text.prototype.insertTemplate.call(this); // original input
120+
// $result.attr("disabled", true).css("background", "lightgray").val(bCastIP);
121+
$result.val("");
122+
return $result;
123+
},
124+
// editing: false
125+
});
126+
113127
// Wake-up Action Column
114128
gridFields.push({
115129
name: "command", title: "Action",

types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Device struct {
1212
Name string `json:"name"`
1313
Mac string `json:"mac"`
1414
BroadcastIP string `json:"ip"`
15+
Interface string `json:"interface"`
1516
}
1617

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

0 commit comments

Comments
 (0)