Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
chnages for connection address, address being passed without <unix/tc…
Browse files Browse the repository at this point in the history
…p>://<path/port>
  • Loading branch information
shrey-gang committed Nov 9, 2019
1 parent ac66b4f commit 0302461
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions astilectron.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ func (a *Astilectron) listen() (err error) {
// Log
astilog.Debug("Listening...")

var addr string
listenType := "tcp"
/*
* Switching between Unix-Socket and TCP-Socket
Expand All @@ -207,29 +206,25 @@ func (a *Astilectron) listen() (err error) {
*/
if len(a.options.Addr) == 0 {
if runtime.GOOS != "windows" {
addr = filepath.Join(a.paths.DataDirectory(), "astilectron.sock")
a.options.Addr = filepath.Join(a.paths.DataDirectory(), "astilectron.sock")
/*
* Not checking error for this, as this step
* is to avoid any error for net.listen while creation
* of unix socket.
* is to avoid any error for net.listen while
* creation of unix socket.
*/
os.Remove(addr)
os.Remove(a.options.Addr)
listenType = "unix"
a.options.Addr = "unix://" + a.options.Addr
} else {
addr = "127.0.0.1:0"
a.options.Addr = "tcp://" + addr
a.options.Addr = "127.0.0.1:0"
}
} else {
addr = a.options.Addr
if runtime.GOOS != "windows" {
listenType = "unix"
}
a.options.Addr = listenType + "://" + addr
}

// Listen
if a.listener, err = net.Listen(listenType, addr); err != nil {
if a.listener, err = net.Listen(listenType, a.options.Addr); err != nil {
return errors.Wrap(err, listenType+" net.Listen failed")
}

Expand Down

0 comments on commit 0302461

Please sign in to comment.