Skip to content

Commit 6673493

Browse files
committed
go.mod: drop github.com/norouter/norouter
Signed-off-by: Akihiro Suda <[email protected]>
1 parent f256998 commit 6673493

File tree

6 files changed

+129
-518
lines changed

6 files changed

+129
-518
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ require (
2929
github.com/mattn/go-shellwords v1.0.12
3030
github.com/miekg/dns v1.1.54
3131
github.com/mikefarah/yq/v4 v4.33.3
32-
github.com/norouter/norouter v0.6.3
3332
github.com/nxadm/tail v1.4.8
3433
github.com/opencontainers/go-digest v1.0.0
3534
github.com/sethvargo/go-password v0.2.0

go.sum

Lines changed: 0 additions & 515 deletions
Large diffs are not rendered by default.

pkg/bicopy/bicopy.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// From https://raw.githubusercontent.com/norouter/norouter/v0.6.5/pkg/agent/bicopy/bicopy.go
2+
/*
3+
Copyright (C) NoRouter authors.
4+
5+
Copyright (C) libnetwork authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package bicopy
21+
22+
import (
23+
"io"
24+
"sync"
25+
26+
"github.com/sirupsen/logrus"
27+
)
28+
29+
// Bicopy is from https://github.com/rootless-containers/rootlesskit/blob/v0.10.1/pkg/port/builtin/parent/tcp/tcp.go#L73-L104
30+
// (originally from libnetwork, Apache License 2.0)
31+
func Bicopy(x, y io.ReadWriter, quit <-chan struct{}) {
32+
type closeReader interface {
33+
CloseRead() error
34+
}
35+
type closeWriter interface {
36+
CloseWrite() error
37+
}
38+
var wg sync.WaitGroup
39+
var broker = func(to, from io.ReadWriter) {
40+
if _, err := io.Copy(to, from); err != nil {
41+
logrus.WithError(err).Debug("failed to call io.Copy")
42+
}
43+
if fromCR, ok := from.(closeReader); ok {
44+
if err := fromCR.CloseRead(); err != nil {
45+
logrus.WithError(err).Debug("failed to call CloseRead")
46+
}
47+
}
48+
if toCW, ok := to.(closeWriter); ok {
49+
if err := toCW.CloseWrite(); err != nil {
50+
logrus.WithError(err).Debug("failed to call CloseWrite")
51+
}
52+
}
53+
wg.Done()
54+
}
55+
56+
wg.Add(2)
57+
go broker(x, y)
58+
go broker(y, x)
59+
finish := make(chan struct{})
60+
go func() {
61+
wg.Wait()
62+
close(finish)
63+
}()
64+
65+
select {
66+
case <-quit:
67+
case <-finish:
68+
}
69+
if xCloser, ok := x.(io.Closer); ok {
70+
if err := xCloser.Close(); err != nil {
71+
logrus.WithError(err).Debug("failed to call xCloser.Close")
72+
}
73+
}
74+
if yCloser, ok := y.(io.Closer); ok {
75+
if err := yCloser.Close(); err != nil {
76+
logrus.WithError(err).Debug("failed to call yCloser.Close")
77+
}
78+
}
79+
<-finish
80+
// TODO: return copied bytes
81+
}

pkg/editutil/editorcmd/editorcmd.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// From https://raw.githubusercontent.com/norouter/norouter/v0.6.5/cmd/norouter/editorcmd/editorcmd.go
2+
/*
3+
Copyright (C) NoRouter authors.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package editorcmd
19+
20+
import (
21+
"os"
22+
"os/exec"
23+
)
24+
25+
// Detect detects a text editor command.
26+
// Returns an empty string when no editor is found.
27+
func Detect() string {
28+
var candidates = []string{
29+
os.Getenv("VISUAL"),
30+
os.Getenv("EDITOR"),
31+
"editor",
32+
"vim",
33+
"vi",
34+
"emacs",
35+
}
36+
for _, f := range candidates {
37+
if f == "" {
38+
continue
39+
}
40+
x, err := exec.LookPath(f)
41+
if err == nil {
42+
return x
43+
}
44+
}
45+
return ""
46+
}

pkg/editutil/editutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"path/filepath"
99
"strings"
1010

11+
"github.com/lima-vm/lima/pkg/editutil/editorcmd"
1112
"github.com/lima-vm/lima/pkg/store/dirnames"
1213
"github.com/lima-vm/lima/pkg/store/filenames"
13-
"github.com/norouter/norouter/cmd/norouter/editorcmd"
1414
"github.com/sirupsen/logrus"
1515
)
1616

pkg/hostagent/port_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"strconv"
1010
"strings"
1111

12+
"github.com/lima-vm/lima/pkg/bicopy"
1213
"github.com/lima-vm/lima/pkg/guestagent/api"
1314
"github.com/lima-vm/sshocker/pkg/ssh"
14-
"github.com/norouter/norouter/pkg/agent/bicopy"
1515
"github.com/sirupsen/logrus"
1616
)
1717

0 commit comments

Comments
 (0)