Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unix socket support on server side #704

Closed
wants to merge 1 commit into from

Conversation

maskedeken
Copy link

No description provided.

@coveralls
Copy link

Coverage Status

Coverage remained the same at ?% when pulling 5b2ee50 on maskedeken:master into 9f2ff06 on xtaci:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at ?% when pulling 5b2ee50 on maskedeken:master into 9f2ff06 on xtaci:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at ?% when pulling 5b2ee50 on maskedeken:master into 9f2ff06 on xtaci:master.

@xtaci
Copy link
Owner

xtaci commented Jul 17, 2019

Could you tell me under what circumstances this might be used?

@maskedeken
Copy link
Author

Could you tell me under what circumstances this might be used?

Some services like v2ray could serve as a unix socket, which is hiding the listening port on a censored system like AliCloud

@xtaci
Copy link
Owner

xtaci commented Jul 17, 2019

why not just listen on 127.0.0.1?

@maskedeken
Copy link
Author

why not just listen on 127.0.0.1?

besides, unix socket is faster than tcp socket.

UNIX domain sockets know that they’re executing on the same system, so they can avoid some checks and operations (like routing); which makes them faster and lighter than IP sockets. So if you plan to communicate with processes on the same host, this is a better option than IP sockets.

@xtaci
Copy link
Owner

xtaci commented Jul 19, 2019

how about re-try scheme? like:

var c conn
if c, err := net.Dial("tcp", xxx) err ==nil{
} else if c, err := net.Dial("unix", xxx);err==nil{
}

then we dont' have to specify unix://

@xtaci
Copy link
Owner

xtaci commented Jul 23, 2019

any comment?

@maskedeken
Copy link
Author

any comment?

I don't think that's a good idea. using try/catch as if/else is a bad practice.

@xtaci
Copy link
Owner

xtaci commented Jul 23, 2019

@xtaci
Copy link
Owner

xtaci commented Jul 23, 2019

or, we can just try parse target to IP address and Port

@maskedeken
Copy link
Author

or, we can just try parse target to IP address and Port

if you don't like the unix:// prefix, error checking is the only way to dial the right conn

@xtaci
Copy link
Owner

xtaci commented Jul 23, 2019

	// check if target is unix domain socket
	var isUnix bool
	if _, _, err := net.SplitHostPort(config.Target); err != nil {
		isUnix = true
	}

a simple check, though not strict

@maskedeken
Copy link
Author

	// check if target is unix domain socket
	var isUnix bool
	if _, _, err := net.SplitHostPort(config.Target); err != nil {
		isUnix = true
	}

a simple check, though not strict

Great

@xtaci xtaci closed this Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants