snail007/goproxy · error

unkown parent type %s

Error message

unkown parent type %s

What it means

The TCP service callback connects to a parent based on cfg.ParentType (tcp/tls/udp). This error is the switch's default branch: the configured ParentType value does not match any supported type, so the connection is dropped, logged, and the incoming connection closed.

Source

Thrown at services/tcp.go:77

func (s *TCP) Clean() {
	s.StopService()
}
func (s *TCP) callback(inConn net.Conn) {
	defer func() {
		if err := recover(); err != nil {
			log.Printf("%s conn handler crashed with err : %s \nstack: %s", s.cfg.Protocol(), err, string(debug.Stack()))
		}
	}()
	var err error
	switch *s.cfg.ParentType {
	case TYPE_TCP:
		fallthrough
	case TYPE_TLS:
		err = s.OutToTCP(&inConn)
	case TYPE_UDP:
		err = s.OutToUDP(&inConn)
	default:
		err = fmt.Errorf("unkown parent type %s", *s.cfg.ParentType)
	}
	if err != nil {
		log.Printf("connect to %s parent %s fail, ERR:%s", *s.cfg.ParentType, *s.cfg.Parent, err)
		utils.CloseConn(&inConn)
	}
}
func (s *TCP) OutToTCP(inConn *net.Conn) (err error) {
	var outConn net.Conn
	var _outConn interface{}
	_outConn, err = s.outPool.Pool.Get()
	if err == nil {
		outConn = _outConn.(net.Conn)
	}
	if err != nil {
		log.Printf("connect to %s , err:%s", *s.cfg.Parent, err)
		utils.CloseConn(inConn)
		return
	}

View on GitHub (pinned to e6d6a821db)

Solutions

  1. Set parent_type in the config to a supported value (tcp, tls, or udp as handled in services/tcp.go)
  2. Check for whitespace/case issues in the config value and trim/normalize it
  3. Verify the binary build supports the configured parent type and upgrade if needed
  4. If parent should be optional, confirm the default value is applied when the field is empty

Example fix

// before
// parent_type=tcps   (unrecognized)
// after
// parent_type=tls
Defensive patterns

Strategy: validation

Validate before calling

switch strings.ToLower(strings.TrimSpace(cfg.ParentType)) {
case "tcp", "tls", "udp":
    // ok
default:
    return fmt.Errorf("parent_type %q must be tcp|tls|udp", cfg.ParentType)
}

Try / catch

if err := svc.Start(); err != nil {
    if strings.Contains(err.Error(), "unkown parent type") {
        log.Fatalf("fix parent_type in config: got %q, want tcp|tls|udp", cfg.ParentType)
    }
}

Prevention

When it happens

Trigger: *s.cfg.ParentType holds a value other than the handled TYPE_TCP/TYPE_TLS/TYPE_UDP constants — e.g. an empty string, wrong case, or an unsupported mode like 'kcp' in a build that does not handle it — causing callback to hit default and fail.

Common situations: Missing/blank parent_type in the config file; typo such as 'TCP' vs 'tcp' depending on parsing; config copied from a version supporting a parent type this build does not compile in.

Related errors


AI-assisted analysis of snail007/goproxy@e6d6a821db (2026-09-03). Data as JSON: /api/errors/534797cbcf103806. Report an issue: GitHub.