-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework new mechanism with the script
- Loading branch information
Showing
12 changed files
with
219 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dhcp-clients-webapp-backend/bin/ | ||
dhcp-clients-webapp-backend/tmp/ | ||
.docker-image | ||
|
||
test-db.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package trackerdb | ||
|
||
import ( | ||
"encoding/json" | ||
"net" | ||
"time" | ||
|
||
// import sqlite3 driver, so that database/sql package will know how to deal with "sqlite3" type | ||
_ "github.com/mattn/go-sqlite3" | ||
) | ||
|
||
// DhcpClient represents the structure for a DHCP client. | ||
// The DHCP client might be currently connected to the server or not; in other words this | ||
// may represent a DHCP client that has been connected in the past, but currently is not. | ||
type DhcpClient struct { | ||
MacAddr net.HardwareAddr | ||
Hostname string | ||
HasStaticIP bool | ||
FriendlyName string | ||
LastSeen time.Time | ||
} | ||
|
||
// MarshalJSON customizes the JSON serialization for DhcpClientData | ||
func (d DhcpClient) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(&struct { | ||
MacAddr string `json:"mac_addr"` | ||
Hostname string `json:"hostname"` | ||
HasStaticIP bool `json:"has_static_ip"` | ||
FriendlyName string `json:"friendly_name"` | ||
LastSeen int64 `json:"last_seen"` | ||
}{ | ||
MacAddr: d.MacAddr.String(), | ||
Hostname: d.Hostname, | ||
HasStaticIP: d.HasStaticIP, | ||
FriendlyName: d.FriendlyName, | ||
LastSeen: d.LastSeen.Unix(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.