"
16 | }
17 | return s
18 | }
19 |
20 | // Protocol returns the ICMPv4 protocol number.
21 | func (typ ICMPType) Protocol() int {
22 | return iana.ProtocolICMP
23 | }
24 |
25 | // An ICMPFilter represents an ICMP message filter for incoming
26 | // packets. The filter belongs to a packet delivery path on a host and
27 | // it cannot interact with forwarding packets or tunnel-outer packets.
28 | //
29 | // Note: RFC 2460 defines a reasonable role model and it works not
30 | // only for IPv6 but IPv4. A node means a device that implements IP.
31 | // A router means a node that forwards IP packets not explicitly
32 | // addressed to itself, and a host means a node that is not a router.
33 | type ICMPFilter struct {
34 | icmpFilter
35 | }
36 |
37 | // Accept accepts incoming ICMP packets including the type field value
38 | // typ.
39 | func (f *ICMPFilter) Accept(typ ICMPType) {
40 | f.accept(typ)
41 | }
42 |
43 | // Block blocks incoming ICMP packets including the type field value
44 | // typ.
45 | func (f *ICMPFilter) Block(typ ICMPType) {
46 | f.block(typ)
47 | }
48 |
49 | // SetAll sets the filter action to the filter.
50 | func (f *ICMPFilter) SetAll(block bool) {
51 | f.setAll(block)
52 | }
53 |
54 | // WillBlock reports whether the ICMP type will be blocked.
55 | func (f *ICMPFilter) WillBlock(typ ICMPType) bool {
56 | return f.willBlock(typ)
57 | }
58 |
--------------------------------------------------------------------------------
/src/github.com/context/x_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package context_test
6 |
7 | import (
8 | . "context"
9 | "testing"
10 | )
11 |
12 | func TestBackground(t *testing.T) { XTestBackground(t) }
13 | func TestTODO(t *testing.T) { XTestTODO(t) }
14 | func TestWithCancel(t *testing.T) { XTestWithCancel(t) }
15 | func TestParentFinishesChild(t *testing.T) { XTestParentFinishesChild(t) }
16 | func TestChildFinishesFirst(t *testing.T) { XTestChildFinishesFirst(t) }
17 | func TestDeadline(t *testing.T) { XTestDeadline(t) }
18 | func TestTimeout(t *testing.T) { XTestTimeout(t) }
19 | func TestCanceledTimeout(t *testing.T) { XTestCanceledTimeout(t) }
20 | func TestValues(t *testing.T) { XTestValues(t) }
21 | func TestAllocs(t *testing.T) { XTestAllocs(t, testing.Short, testing.AllocsPerRun) }
22 | func TestSimultaneousCancels(t *testing.T) { XTestSimultaneousCancels(t) }
23 | func TestInterlockedCancels(t *testing.T) { XTestInterlockedCancels(t) }
24 | func TestLayersCancel(t *testing.T) { XTestLayersCancel(t) }
25 | func TestLayersTimeout(t *testing.T) { XTestLayersTimeout(t) }
26 | func TestCancelRemoves(t *testing.T) { XTestCancelRemoves(t) }
27 | func TestWithCancelCanceledParent(t *testing.T) { XTestWithCancelCanceledParent(t) }
28 | func TestWithValueChecksKey(t *testing.T) { XTestWithValueChecksKey(t) }
29 | func TestDeadlineExceededSupportsTimeout(t *testing.T) { XTestDeadlineExceededSupportsTimeout(t) }
30 |
--------------------------------------------------------------------------------
/package.sh:
--------------------------------------------------------------------------------
1 | # compile for version
2 | make
3 | if [ $? -ne 0 ]; then
4 | echo "make error"
5 | exit 1
6 | fi
7 |
8 | frp_version=`./bin/frps --version`
9 | echo "build version: $frp_version"
10 |
11 | # cross_compiles
12 | make -f ./Makefile.cross-compiles
13 |
14 | rm -rf ./packages
15 | mkdir ./packages
16 |
17 | os_all='linux windows darwin'
18 | arch_all='386 amd64 arm mips64 mips64le mips mipsle'
19 |
20 | for os in $os_all; do
21 | for arch in $arch_all; do
22 | frp_dir_name="frp_${frp_version}_${os}_${arch}"
23 | frp_path="./packages/frp_${frp_version}_${os}_${arch}"
24 |
25 | if [ "x${os}" = x"windows" ]; then
26 | if [ ! -f "./frpc_${os}_${arch}.exe" ]; then
27 | continue
28 | fi
29 | if [ ! -f "./frps_${os}_${arch}.exe" ]; then
30 | continue
31 | fi
32 | mkdir ${frp_path}
33 | mv ./src/frpc_${os}_${arch}.exe ${frp_path}/frpc.exe
34 | mv ./src/frps_${os}_${arch}.exe ${frp_path}/frps.exe
35 | else
36 | if [ ! -f "./frpc_${os}_${arch}" ]; then
37 | continue
38 | fi
39 | if [ ! -f "./frps_${os}_${arch}" ]; then
40 | continue
41 | fi
42 | mkdir ${frp_path}
43 | mv ./src/frpc_${os}_${arch} ${frp_path}/frpc
44 | mv ./src/frps_${os}_${arch} ${frp_path}/frps
45 | fi
46 | cp ./LICENSE ${frp_path}
47 | cp ./src/conf/* ${frp_path}
48 |
49 | # packages
50 | cd ./packages
51 | if [ "x${os}" = x"windows" ]; then
52 | zip -rq ${frp_dir_name}.zip ${frp_dir_name}
53 | else
54 | tar -zcf ${frp_dir_name}.tar.gz ${frp_dir_name}
55 | fi
56 | cd ..
57 | rm -rf ${frp_path}
58 | done
59 | done
60 |
--------------------------------------------------------------------------------
/src/utils/vhost/resource.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 fatedier, fatedier@gmail.com
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package vhost
16 |
17 | import (
18 | "io/ioutil"
19 | "net/http"
20 | "strings"
21 |
22 | "utils/version"
23 | )
24 |
25 | const (
26 | NotFound = `
27 |
28 |
29 | Not Found
30 |
37 |
38 |
39 | The page you visit not found.
40 | Sorry, the page you are looking for is currently unavailable.
41 | Please try again later.
42 | The server is powered by www.lu8.top.
43 | Faithfully yours, frp.
44 |
45 |
46 | `
47 | )
48 |
49 | func notFoundResponse() *http.Response {
50 | header := make(http.Header)
51 | header.Set("server", "frp/"+version.Full())
52 | header.Set("Content-Type", "text/html")
53 | res := &http.Response{
54 | Status: "Not Found",
55 | StatusCode: 404,
56 | Proto: "HTTP/1.0",
57 | ProtoMajor: 1,
58 | ProtoMinor: 0,
59 | Header: header,
60 | Body: ioutil.NopCloser(strings.NewReader(NotFound)),
61 | }
62 | return res
63 | }
64 |
--------------------------------------------------------------------------------
/src/utils/version/version_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 fatedier, fatedier@gmail.com
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package version
16 |
17 | import (
18 | "fmt"
19 | "strconv"
20 | "strings"
21 | "testing"
22 |
23 | "github.com/stretchr/testify/assert"
24 | )
25 |
26 | func TestFull(t *testing.T) {
27 | assert := assert.New(t)
28 | version := Full()
29 | arr := strings.Split(version, ".")
30 | assert.Equal(3, len(arr))
31 |
32 | proto, err := strconv.ParseInt(arr[0], 10, 64)
33 | assert.NoError(err)
34 | assert.True(proto >= 0)
35 |
36 | major, err := strconv.ParseInt(arr[1], 10, 64)
37 | assert.NoError(err)
38 | assert.True(major >= 0)
39 |
40 | minor, err := strconv.ParseInt(arr[2], 10, 64)
41 | assert.NoError(err)
42 | assert.True(minor >= 0)
43 | }
44 |
45 | func TestVersion(t *testing.T) {
46 | assert := assert.New(t)
47 | proto := Proto(Full())
48 | major := Major(Full())
49 | minor := Minor(Full())
50 | parseVerion := fmt.Sprintf("%d.%d.%d", proto, major, minor)
51 | version := Full()
52 | assert.Equal(parseVerion, version)
53 | }
54 |
55 | func TestCompact(t *testing.T) {
56 | assert := assert.New(t)
57 | ok, _ := Compat("0.9.0")
58 | assert.False(ok)
59 |
60 | ok, _ = Compat("10.0.0")
61 | assert.True(ok)
62 |
63 | ok, _ = Compat("0.10.0")
64 | assert.True(ok)
65 | }
66 |
--------------------------------------------------------------------------------