github.com/EagleQL/Xray-core@v1.4.3/transport/internet/system_dialer_context.go (about)

     1  package internet
     2  
     3  import "context"
     4  
     5  type systemDialer int
     6  
     7  const systemDialerKey systemDialer = 0
     8  
     9  func ContextWithLookupDomain(ctx context.Context, domain string) context.Context {
    10  	return context.WithValue(ctx, systemDialerKey, domain)
    11  }
    12  
    13  func LookupDomainFromContext(ctx context.Context) string {
    14  	if domain, ok := ctx.Value(systemDialerKey).(string); ok {
    15  		return domain
    16  	}
    17  	return ""
    18  }