mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
p2p: fix marshaling of NAT in TOML (#31192)
This fixes an issue where a nat.Interface unmarshaled from the TOML config file could not be re-marshaled to TOML correctly. Fixes #31183
This commit is contained in:
parent
e5bc789185
commit
c113e3b5b1
1 changed files with 8 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ package p2p
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"encoding"
|
||||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/mclock"
|
||||
|
|
@ -135,6 +136,13 @@ type configNAT struct {
|
|||
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 {
|
||||
n, err := nat.Parse(string(input))
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue