File tree 2 files changed +85
-0
lines changed 2 files changed +85
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You may
4
+ # not use this file except in compliance with the License. A copy of the
5
+ # License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is distributed
10
+ # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11
+ # express or implied. See the License for the specific language governing
12
+ # permissions and limitations under the License.
13
+
14
+ EXTRAGOARGS? =
15
+
16
+ SOURCES: =$(shell find . -name '* .go')
17
+
18
+ all : send2vsock
19
+
20
+ send2vsock : $(SOURCES )
21
+ go build $(EXTRAGOARGS ) -o $@
22
+
23
+ test :
24
+ go test ./... $(EXTRAGOARGS )
25
+
26
+ clean :
27
+ -rm -f send2vsock
28
+
29
+ distclean : clean
30
+
31
+ # Install is a noop here, for now.
32
+ install :
33
+
34
+ .PHONY : clean distclean all install test integ-test
35
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License"). You may
4
+ // not use this file except in compliance with the License. A copy of the
5
+ // License is located at
6
+ //
7
+ // http://aws.amazon.com/apache2.0/
8
+ //
9
+ // or in the "license" file accompanying this file. This file is distributed
10
+ // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11
+ // express or implied. See the License for the specific language governing
12
+ // permissions and limitations under the License.
13
+
14
+ package main
15
+
16
+ import (
17
+ "fmt"
18
+ "github.com/mdlayher/vsock"
19
+ "io"
20
+ "os"
21
+ "strconv"
22
+ )
23
+
24
+ func main () {
25
+ if len (os .Args ) != 3 {
26
+ fmt .Fprintf (os .Stderr , "Usage: send2vsock CID PORT\n " )
27
+ os .Exit (1 )
28
+ }
29
+
30
+ cid , err := strconv .Atoi (os .Args [1 ])
31
+ if err != nil {
32
+ fmt .Fprintf (os .Stderr , "invalid CID: %+v\n " , err )
33
+ os .Exit (1 )
34
+ }
35
+
36
+ port , err := strconv .Atoi (os .Args [2 ])
37
+ if err != nil {
38
+ fmt .Fprintf (os .Stderr , "invalid port: %+v\n " , err )
39
+ os .Exit (1 )
40
+ }
41
+
42
+ conn , err := vsock .Dial (uint32 (cid ), uint32 (port ))
43
+ if err != nil {
44
+ fmt .Fprintf (os .Stderr , "failed to connect to the vsock: %+v\n " , err )
45
+ os .Exit (1 )
46
+ }
47
+ defer conn .Close ()
48
+
49
+ io .Copy (conn , os .Stdin )
50
+ }
You can’t perform that action at this time.
0 commit comments