浏览代码

lib/upnp: Fix port order

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/2980
Audrius Butkevicius 9 年之前
父节点
当前提交
1c7af1a72e
共有 3 个文件被更改,包括 8 次插入4 次删除
  1. 5 1
      lib/osutil/mkdirall_windows.go
  2. 2 2
      lib/upnp/igd.go
  3. 1 1
      lib/upnp/igd_service.go

+ 5 - 1
lib/osutil/mkdirall_windows.go

@@ -25,7 +25,11 @@ func MkdirAll(path string, perm os.FileMode) error {
 		if dir.IsDir() {
 			return nil
 		}
-		return &os.PathError{"mkdir", path, syscall.ENOTDIR}
+		return &os.PathError{
+			Op:   "mkdir",
+			Path: path,
+			Err:  syscall.ENOTDIR,
+		}
 	}
 
 	// Slow path: make sure parent exists and then call Mkdir for path.

+ 2 - 2
lib/upnp/igd.go

@@ -50,9 +50,9 @@ func (n *IGD) URL() *url.URL {
 // if action is fails for _any_ of the relevant services. For this reason, it
 // is generally better to configure port mapping for each individual service
 // instead.
-func (n *IGD) AddPortMapping(protocol nat.Protocol, externalPort, internalPort int, description string, duration time.Duration) (int, error) {
+func (n *IGD) AddPortMapping(protocol nat.Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error) {
 	for _, service := range n.services {
-		err := service.AddPortMapping(n.localIPAddress, protocol, externalPort, internalPort, description, duration)
+		err := service.AddPortMapping(n.localIPAddress, protocol, internalPort, externalPort, description, duration)
 		if err != nil {
 			return externalPort, err
 		}

+ 1 - 1
lib/upnp/igd_service.go

@@ -26,7 +26,7 @@ type IGDService struct {
 }
 
 // AddPortMapping adds a port mapping to the specified IGD service.
-func (s *IGDService) AddPortMapping(localIPAddress net.IP, protocol nat.Protocol, externalPort, internalPort int, description string, duration time.Duration) error {
+func (s *IGDService) AddPortMapping(localIPAddress net.IP, protocol nat.Protocol, internalPort, externalPort int, description string, duration time.Duration) error {
 	tpl := `<u:AddPortMapping xmlns:u="%s">
 	<NewRemoteHost></NewRemoteHost>
 	<NewExternalPort>%d</NewExternalPort>