Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
035d600f
提交
035d600f
authored
9月 14, 2014
作者:
Juan Batiz-Benet
提交者:
Brian Tiger Chow
9月 22, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Godeps: use in net + new multiaddr
上级
06b651c4
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
181 行增加
和
22 行删除
+181
-22
Godeps.json
Godeps/Godeps.json
+8
-3
context.go
...workspace/src/code.google.com/p/go.net/context/context.go
+0
-0
context_test.go
...pace/src/code.google.com/p/go.net/context/context_test.go
+0
-0
withtimeout_test.go
.../src/code.google.com/p/go.net/context/withtimeout_test.go
+26
-0
codec.go
...ps/_workspace/src/github.com/jbenet/go-multiaddr/codec.go
+7
-5
net.go
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/net.go
+77
-0
net_test.go
..._workspace/src/github.com/jbenet/go-multiaddr/net_test.go
+49
-0
core.go
core/core.go
+3
-3
message.go
net/message/message.go
+1
-1
mux.go
net/mux/mux.go
+2
-2
mux.pb.go
net/mux/mux.pb.go
+1
-1
mux_test.go
net/mux/mux_test.go
+2
-2
request.go
net/service/request.go
+1
-1
request.pb.go
net/service/request.pb.go
+1
-1
service.go
net/service/service.go
+1
-1
service_test.go
net/service/service_test.go
+2
-2
没有找到文件。
Godeps/Godeps.json
浏览文件 @
035d600f
{
"ImportPath"
:
"github.com/jbenet/go-ipfs"
,
"GoVersion"
:
"go1.3
.1
"
,
"GoVersion"
:
"go1.3"
,
"Packages"
:
[
"./..."
],
...
...
@@ -20,6 +20,11 @@
"Rev"
:
"00a7d3b31bbab5795b4a51933c04fc2768242970"
},
{
"ImportPath"
:
"code.google.com/p/go.net/context"
,
"Comment"
:
"null-144"
,
"Rev"
:
"ad01a6fcc8a19d3a4478c836895ffe883bd2ceab"
},
{
"ImportPath"
:
"code.google.com/p/gogoprotobuf/proto"
,
"Rev"
:
"6c980277330804e94257ac7ef70a3adbe1641059"
},
...
...
@@ -55,8 +60,8 @@
},
{
"ImportPath"
:
"github.com/jbenet/go-multiaddr"
,
"Comment"
:
"0.1.2"
,
"Rev"
:
"
b90678896b52c3e5a4c8176805c6facc3fe3eb82
"
"Comment"
:
"0.1.2
-2-g0624ab3
"
,
"Rev"
:
"
0624ab3bf754d013585c5d07f0100ba34901a689
"
},
{
"ImportPath"
:
"github.com/jbenet/go-multihash"
,
...
...
Godeps/_workspace/src/code.google.com/p/go.net/context/context.go
0 → 100644
浏览文件 @
035d600f
差异被折叠。
点击展开。
Godeps/_workspace/src/code.google.com/p/go.net/context/context_test.go
0 → 100644
浏览文件 @
035d600f
差异被折叠。
点击展开。
Godeps/_workspace/src/code.google.com/p/go.net/context/withtimeout_test.go
0 → 100644
浏览文件 @
035d600f
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
context_test
import
(
"fmt"
"time"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
)
func
ExampleWithTimeout
()
{
// Pass a context with a timeout to tell a blocking function that it
// should abandon its work after the timeout elapses.
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
100
*
time
.
Millisecond
)
select
{
case
<-
time
.
After
(
200
*
time
.
Millisecond
)
:
fmt
.
Println
(
"overslept"
)
case
<-
ctx
.
Done
()
:
fmt
.
Println
(
ctx
.
Err
())
// prints "context deadline exceeded"
}
// Output:
// context deadline exceeded
}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/codec.go
浏览文件 @
035d600f
...
...
@@ -66,12 +66,14 @@ func bytesToString(b []byte) (ret string, err error) {
func
addressStringToBytes
(
p
*
Protocol
,
s
string
)
[]
byte
{
switch
p
.
Code
{
// ipv4,6
case
4
,
41
:
case
P_IP4
:
// ipv4
return
net
.
ParseIP
(
s
)
.
To4
()
case
P_IP6
:
// ipv6
return
net
.
ParseIP
(
s
)
.
To16
()
// tcp udp dccp sctp
case
6
,
17
,
33
,
132
:
case
P_TCP
,
P_UDP
,
P_DCCP
,
P_SCTP
:
b
:=
make
([]
byte
,
2
)
i
,
err
:=
strconv
.
Atoi
(
s
)
if
err
==
nil
{
...
...
@@ -87,11 +89,11 @@ func addressBytesToString(p *Protocol, b []byte) string {
switch
p
.
Code
{
// ipv4,6
case
4
,
41
:
case
P_IP4
,
P_IP6
:
return
net
.
IP
(
b
)
.
String
()
// tcp udp dccp sctp
case
6
,
17
,
33
,
132
:
case
P_TCP
,
P_UDP
,
P_DCCP
,
P_SCTP
:
i
:=
binary
.
BigEndian
.
Uint16
(
b
)
return
strconv
.
Itoa
(
int
(
i
))
}
...
...
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/net.go
0 → 100644
浏览文件 @
035d600f
package
multiaddr
import
(
"fmt"
"net"
)
var
errIncorrectNetAddr
=
fmt
.
Errorf
(
"incorrect network addr conversion"
)
// FromNetAddr converts a net.Addr type to a Multiaddr.
func
FromNetAddr
(
a
net
.
Addr
)
(
*
Multiaddr
,
error
)
{
switch
a
.
Network
()
{
case
"tcp"
,
"tcp4"
,
"tcp6"
:
ac
,
ok
:=
a
.
(
*
net
.
TCPAddr
)
if
!
ok
{
return
nil
,
errIncorrectNetAddr
}
// Get IP Addr
ipm
,
err
:=
FromIP
(
ac
.
IP
)
if
err
!=
nil
{
return
nil
,
errIncorrectNetAddr
}
// Get TCP Addr
tcpm
,
err
:=
NewMultiaddr
(
fmt
.
Sprintf
(
"/tcp/%d"
,
ac
.
Port
))
if
err
!=
nil
{
return
nil
,
errIncorrectNetAddr
}
// Encapsulate
return
ipm
.
Encapsulate
(
tcpm
),
nil
case
"udp"
,
"upd4"
,
"udp6"
:
ac
,
ok
:=
a
.
(
*
net
.
UDPAddr
)
if
!
ok
{
return
nil
,
errIncorrectNetAddr
}
// Get IP Addr
ipm
,
err
:=
FromIP
(
ac
.
IP
)
if
err
!=
nil
{
return
nil
,
errIncorrectNetAddr
}
// Get UDP Addr
udpm
,
err
:=
NewMultiaddr
(
fmt
.
Sprintf
(
"/udp/%d"
,
ac
.
Port
))
if
err
!=
nil
{
return
nil
,
errIncorrectNetAddr
}
// Encapsulate
return
ipm
.
Encapsulate
(
udpm
),
nil
case
"ip"
,
"ip4"
,
"ip6"
:
ac
,
ok
:=
a
.
(
*
net
.
IPAddr
)
if
!
ok
{
return
nil
,
errIncorrectNetAddr
}
return
FromIP
(
ac
.
IP
)
default
:
return
nil
,
fmt
.
Errorf
(
"unknown network %v"
,
a
.
Network
())
}
}
// FromIP converts a net.IP type to a Multiaddr.
func
FromIP
(
ip
net
.
IP
)
(
*
Multiaddr
,
error
)
{
switch
{
case
ip
.
To4
()
!=
nil
:
return
NewMultiaddr
(
"/ip4/"
+
ip
.
String
())
case
ip
.
To16
()
!=
nil
:
return
NewMultiaddr
(
"/ip6/"
+
ip
.
String
())
default
:
return
nil
,
errIncorrectNetAddr
}
}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/net_test.go
0 → 100644
浏览文件 @
035d600f
package
multiaddr
import
(
"net"
"testing"
)
type
GenFunc
func
()
(
*
Multiaddr
,
error
)
func
testConvert
(
t
*
testing
.
T
,
s
string
,
gen
GenFunc
)
{
m
,
err
:=
gen
()
if
err
!=
nil
{
t
.
Fatal
(
"failed to generate."
)
}
if
s2
,
_
:=
m
.
String
();
err
!=
nil
||
s2
!=
s
{
t
.
Fatal
(
"failed to convert: "
+
s
+
" != "
+
s2
)
}
}
func
TestFromIP4
(
t
*
testing
.
T
)
{
testConvert
(
t
,
"/ip4/10.20.30.40"
,
func
()
(
*
Multiaddr
,
error
)
{
return
FromIP
(
net
.
ParseIP
(
"10.20.30.40"
))
})
}
func
TestFromIP6
(
t
*
testing
.
T
)
{
testConvert
(
t
,
"/ip6/2001:4860:0:2001::68"
,
func
()
(
*
Multiaddr
,
error
)
{
return
FromIP
(
net
.
ParseIP
(
"2001:4860:0:2001::68"
))
})
}
func
TestFromTCP
(
t
*
testing
.
T
)
{
testConvert
(
t
,
"/ip4/10.20.30.40/tcp/1234"
,
func
()
(
*
Multiaddr
,
error
)
{
return
FromNetAddr
(
&
net
.
TCPAddr
{
IP
:
net
.
ParseIP
(
"10.20.30.40"
),
Port
:
1234
,
})
})
}
func
TestFromUDP
(
t
*
testing
.
T
)
{
testConvert
(
t
,
"/ip4/10.20.30.40/udp/1234"
,
func
()
(
*
Multiaddr
,
error
)
{
return
FromNetAddr
(
&
net
.
UDPAddr
{
IP
:
net
.
ParseIP
(
"10.20.30.40"
),
Port
:
1234
,
})
})
}
core/core.go
浏览文件 @
035d600f
...
...
@@ -77,8 +77,8 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
var
(
net
*
swarm
.
Swarm
// TODO: refactor so we can use IpfsRouting interface instead of being DHT-specific
route
*
dht
.
IpfsDHT
swap
*
bitswap
.
BitSwap
route
*
dht
.
IpfsDHT
swap
*
bitswap
.
BitSwap
)
if
online
{
...
...
@@ -134,7 +134,7 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
return
nil
,
err
}
addresses
=
[]
*
ma
.
Multiaddr
{
maddr
}
addresses
=
[]
*
ma
.
Multiaddr
{
maddr
}
}
skb
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
cfg
.
Identity
.
PrivKey
)
...
...
net/message/message.go
浏览文件 @
035d600f
...
...
@@ -3,7 +3,7 @@ package message
import
(
peer
"github.com/jbenet/go-ipfs/peer"
proto
"code.google.com/p/goprotobuf/proto"
proto
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/goprotobuf/proto"
)
// Message represents a packet of information sent to or received from a
...
...
net/mux/mux.go
浏览文件 @
035d600f
...
...
@@ -6,8 +6,8 @@ import (
msg
"github.com/jbenet/go-ipfs/net/message"
u
"github.com/jbenet/go-ipfs/util"
context
"code.google.com/p/go.net/context"
proto
"code.google.com/p/goprotobuf/proto"
context
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/go.net/context"
proto
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/goprotobuf/proto"
)
// Protocol objects produce + consume raw data. They are added to the Muxer
...
...
net/mux/mux.pb.go
浏览文件 @
035d600f
...
...
@@ -13,7 +13,7 @@ It has these top-level messages:
*/
package
mux
import
proto
"code.google.com/p/gogoprotobuf/proto"
import
proto
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/gogoprotobuf/proto"
import
json
"encoding/json"
import
math
"math"
...
...
net/mux/mux_test.go
浏览文件 @
035d600f
...
...
@@ -9,9 +9,9 @@ import (
msg
"github.com/jbenet/go-ipfs/net/message"
peer
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
mh
"github.com/jbenet/go-multihash"
mh
"github.com/jbenet/go-
ipfs/Godeps/_workspace/src/github.com/jbenet/go-
multihash"
context
"code.google.com/p/go.net/context"
context
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/go.net/context"
)
type
TestProtocol
struct
{
...
...
net/service/request.go
浏览文件 @
035d600f
...
...
@@ -6,7 +6,7 @@ import (
msg
"github.com/jbenet/go-ipfs/net/message"
peer
"github.com/jbenet/go-ipfs/peer"
proto
"code.google.com/p/goprotobuf/proto"
proto
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/goprotobuf/proto"
)
const
(
...
...
net/service/request.pb.go
浏览文件 @
035d600f
...
...
@@ -13,7 +13,7 @@ It has these top-level messages:
*/
package
service
import
proto
"code.google.com/p/gogoprotobuf/proto"
import
proto
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/gogoprotobuf/proto"
import
json
"encoding/json"
import
math
"math"
...
...
net/service/service.go
浏览文件 @
035d600f
...
...
@@ -7,7 +7,7 @@ import (
msg
"github.com/jbenet/go-ipfs/net/message"
u
"github.com/jbenet/go-ipfs/util"
context
"code.google.com/p/go.net/context"
context
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/go.net/context"
)
// Handler is an interface that objects must implement in order to handle
...
...
net/service/service_test.go
浏览文件 @
035d600f
...
...
@@ -8,8 +8,8 @@ import (
msg
"github.com/jbenet/go-ipfs/net/message"
peer
"github.com/jbenet/go-ipfs/peer"
context
"code.google.com/p/go.net/context"
mh
"github.com/jbenet/go-multihash"
context
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/go.net/context"
mh
"github.com/jbenet/go-
ipfs/Godeps/_workspace/src/github.com/jbenet/go-
multihash"
)
// ReverseHandler reverses all Data it receives and sends it back.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论