Update dependencies
This commit is contained in:
22
vendor/github.com/kortschak/wol/LICENSE
generated
vendored
Normal file
22
vendor/github.com/kortschak/wol/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright ©2015 Dan Kortschak. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
15
vendor/github.com/kortschak/wol/README.md
generated
vendored
Normal file
15
vendor/github.com/kortschak/wol/README.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
wol implements a very simple Wake On LAN client and supporting Wake function.
|
||||
|
||||
## Installation
|
||||
|
||||
wol requires a [Go](http://golang.org) installation.
|
||||
|
||||
## Documentation
|
||||
|
||||
http://godoc.org/github.com/kortschak/wol
|
||||
|
||||
## License
|
||||
|
||||
wol is distributed under a modified BSD license.
|
||||
|
||||
|
||||
54
vendor/github.com/kortschak/wol/wol.go
generated
vendored
Normal file
54
vendor/github.com/kortschak/wol/wol.go
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright ©2016 Dan Kortschak. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package wol provides a Wake On LAN function.
|
||||
package wol
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
)
|
||||
|
||||
const magicLen = 6 + 16*6
|
||||
|
||||
// Wake sends a Wake On LAN magic packet for the given MAC address
|
||||
// at the given remote address. If local is not nil, it is used as
|
||||
// the local address for the connection to send on.
|
||||
func Wake(mac net.HardwareAddr, pass []byte, local, remote *net.UDPAddr) error {
|
||||
if len(mac) != 6 {
|
||||
return errors.New("wol: bad MAC address")
|
||||
}
|
||||
switch len(pass) {
|
||||
default:
|
||||
return errors.New("wol: bad password length")
|
||||
case 0, 6:
|
||||
}
|
||||
var magic [magicLen + 6]byte
|
||||
copy(magic[:], []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff})
|
||||
buf := bytes.NewBuffer(magic[:6])
|
||||
for i := 0; i < 16; i++ {
|
||||
buf.Write(mac)
|
||||
}
|
||||
buf.Write(pass)
|
||||
if buf.Len() != magicLen+len(pass) {
|
||||
panic("wol: unexpected packet length")
|
||||
}
|
||||
|
||||
conn, err := net.DialUDP("udp", local, remote)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
n, err := conn.Write(buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n < magicLen+len(pass) {
|
||||
return io.ErrShortWrite
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user