From 47c887338f10cf05484e695cbf55c4fd0fd06bce Mon Sep 17 00:00:00 2001 From: Jonathan Gillham Date: Fri, 29 Aug 2014 09:44:41 +0100 Subject: [PATCH] Made App Engine runtime compatible. --- certgen.go | 2 +- net.go | 18 ++++++++++++++++++ net_noop.go | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 net.go create mode 100644 net_noop.go diff --git a/certgen.go b/certgen.go index a410bf4..76dc5e5 100644 --- a/certgen.go +++ b/certgen.go @@ -77,7 +77,7 @@ func NewTLSCertPair(organization string, validUntil time.Time, extraHosts []stri "localhost": true, } - addrs, err := net.InterfaceAddrs() + addrs, err := interfaceAddrs() if err != nil { return nil, nil, err } diff --git a/net.go b/net.go new file mode 100644 index 0000000..07d1606 --- /dev/null +++ b/net.go @@ -0,0 +1,18 @@ +// Copyright (c) 2013-2014 Conformal Systems LLC. +// Use of this source code is governed by an ISC +// license that can be found in the LICENSE file. + +// +build !appengine + +package btcutil + +import ( + "net" +) + +// interfaceAddrs returns a list of the system's network interface addresses. +// It is wrapped here so that we can substitute it for other functions when +// building for systems that do not allow access to net.InterfaceAddrs(). +func interfaceAddrs() ([]net.Addr, error) { + return net.InterfaceAddrs() +} diff --git a/net_noop.go b/net_noop.go new file mode 100644 index 0000000..3eeffda --- /dev/null +++ b/net_noop.go @@ -0,0 +1,19 @@ +// Copyright (c) 2013-2014 Conformal Systems LLC. +// Use of this source code is governed by an ISC +// license that can be found in the LICENSE file. + +// +build appengine + +package btcutil + +import ( + "net" +) + +// interfaceAddrs returns a list of the system's network interface addresses. +// It is wrapped here so that we can substitute it for a no-op function that +// returns an empty slice of net.Addr when building for systems that do not +// allow access to net.InterfaceAddrs(). +func interfaceAddrs() ([]net.Addr, error) { + return []net.Addr{}, nil +}