mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
p2p: fix marshaling of NAT in TOML
This fixes an issue where a nat.Interface unmarshaled from the TOML config file could not be re-marshaled to TOML correctly.
This commit is contained in:
parent
68de26e346
commit
03f430a304
1 changed files with 8 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ package p2p
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/mclock"
|
"github.com/ethereum/go-ethereum/common/mclock"
|
||||||
|
|
@ -135,6 +136,13 @@ type configNAT struct {
|
||||||
nat.Interface
|
nat.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *configNAT) MarshalText() ([]byte, error) {
|
||||||
|
if tm, ok := w.Interface.(encoding.TextMarshaler); ok {
|
||||||
|
return tm.MarshalText()
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("NAT specification %#v cannot be marshaled", w.Interface)
|
||||||
|
}
|
||||||
|
|
||||||
func (w *configNAT) UnmarshalText(input []byte) error {
|
func (w *configNAT) UnmarshalText(input []byte) error {
|
||||||
n, err := nat.Parse(string(input))
|
n, err := nat.Parse(string(input))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue