本文整理汇总了C#中Brunet.Transport.TransportAddress类的典型用法代码示例。如果您正苦于以下问题:C# TransportAddress类的具体用法?C# TransportAddress怎么用?C# TransportAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransportAddress类属于Brunet.Transport命名空间,在下文中一共展示了TransportAddress类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetEdgeListenerList
/// <summary>Retrieve a given EL Dictionary for the TA Type. This could leak,
/// though that would take the creation of many different EL types and in normal
/// usage there will only be 1 or 2 types.</summary>
static protected Dictionary<int, SimulationEdgeListener> GetEdgeListenerList(TransportAddress.TAType type)
{
if(!_el_map.ContainsKey(type)) {
_el_map[type] = new Dictionary<int, SimulationEdgeListener>();
}
return _el_map[type];
}
开发者ID:pstjuste,项目名称:brunet,代码行数:10,代码来源:SimulationEdgeListener.cs
示例2: Authorize
public override TAAuthorizer.Decision Authorize(TransportAddress a) {
if (_denied_id == ((SimulationTransportAddress)a).ID) {
return TAAuthorizer.Decision.Deny;
} else {
//else this decision should not matter
return TAAuthorizer.Decision.None;
}
}
开发者ID:pstjuste,项目名称:brunet,代码行数:8,代码来源:IDTAAuth.cs
示例3: UpdateTAs
public void UpdateTAs(TransportAddress remote_ta, TransportAddress local_ta)
{
if(_known_tas.Length == 2) {
return;
}
_known_tas = new TransportAddress[2] { _internal_ta[0], local_ta };
_allow_inbound = true;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:8,代码来源:ConeNat.cs
示例4: XmppEdge
/// <summary>Create a XmppEdge.</summary>
public XmppEdge(IEdgeSendHandler send_handler, XmppTransportAddress local_ta,
XmppTransportAddress remote_ta, bool inbound) :
base(send_handler, inbound)
{
_ip = new IdentifierPair();
_local_ta = local_ta;
_remote_ta = remote_ta;
To = remote_ta.JID;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:10,代码来源:XmppEdge.cs
示例5: SubringEdge
/// <summary>Constructor for an outgoing edge, since we don't know the remote
/// id yet, it must be outgoing!</summary>
public SubringEdge(TransportAddress local_ta, TransportAddress remote_ta,
bool inbound, ISender sender, PType ptype) :
base(null, inbound)
{
_ip = new IdentifierPair();
_local_ta = local_ta;
_remote_ta = remote_ta;
_ptype = ptype;
_overlay_sender = sender;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:12,代码来源:SubringEdge.cs
示例6: ConeNat
public ConeNat(TransportAddress ta, int timeout)
{
_external_ta = new TransportAddress[1] { ta };
_internal_ta = new TransportAddress[1] { ((SimulationTransportAddress) ta).Invert() };
_known_tas = _internal_ta;
// TBC uses a staged GC, so values are still in after one timeout
_allowed = new TimeBasedCache<TransportAddress, bool>(timeout / 2);
_allowed.EvictionHandler += HandleEviction;
_allow_inbound = false;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:10,代码来源:ConeNat.cs
示例7: SimulationEdge
public SimulationEdge(IEdgeSendHandler s, int local_id, int remote_id,
bool is_in, int delay, TransportAddress.TAType type) : base(s, is_in)
{
Delay = delay;
LocalID = local_id;
RemoteID = remote_id;
_ta_type = type;
_local_ta = GetTransportAddress(local_id);
_remote_ta = GetTransportAddress(remote_id);
SimEL = s as SimulationEdgeListener;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:11,代码来源:SimulationEdge.cs
示例8: CreateEdgeTo
/**
* This creates Edges of a given type
*/
public void CreateEdgeTo(TransportAddress destination,
EdgeListener.EdgeCreationCallback ecb)
{
TransportAddress.TAType t = destination.TransportAddressType;
if( _el_map.Contains( t ) ) {
EdgeListener el = (EdgeListener)_el_map[ t ];
el.CreateEdgeTo( destination, ecb );
}
else {
ecb(false, null, new EdgeException("No EdgeListener for TA type: " +
t.ToString() ) );
}
}
开发者ID:pstjuste,项目名称:brunet,代码行数:16,代码来源:EdgeFactory.cs
示例9: SubringEdgeListener
/// <summary>Create a SubringEdgeListener.</summary>
/// <param name="shared_node">The overlay used for the transport.</param>
/// <param name="private_node">The overlay needing edges.</param>
public SubringEdgeListener(Node shared_node, Node private_node)
{
_shared_node = shared_node;
_private_node = private_node;
_it = new IdentifierTable();
_local_ta = new SubringTransportAddress(shared_node.Address as AHAddress,
shared_node.Realm);
_ptype = new PType("ns:" + shared_node.Realm);
shared_node.DemuxHandler.GetTypeSource(_ptype).Subscribe(this, null);
_running = 0;
_started = 0;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:18,代码来源:SubringEdgeListener.cs
示例10: Authorize
public override TAAuthorizer.Decision Authorize(TransportAddress a)
{
int id = ((SimulationTransportAddress) a).ID;
if(id == 0) {
return TAAuthorizer.Decision.Allow;
}
if(!_allowed.Contains(id)) {
if(Rand.NextDouble() > Prob) {
_allowed[id] = TAAuthorizer.Decision.Allow;
} else {
_allowed[id] = TAAuthorizer.Decision.Deny;
}
}
return (TAAuthorizer.Decision) _allowed[id];
}
开发者ID:hseom,项目名称:brunet,代码行数:17,代码来源:BrokenTAAuth.cs
示例11: CreateEdgeTo
public override void CreateEdgeTo(TransportAddress ta, EdgeCreationCallback ecb)
{
SubringTransportAddress sta = ta as SubringTransportAddress;
if(sta == null) {
ecb(false, null, new Exception("TA Type is not Subring!"));
} else if(!sta.Namespace.Equals(_shared_node.Realm)) {
ecb(false, null, new Exception("Namespace mismatch"));
} else if(sta.Target.Equals(_private_node.Address)) {
ecb(false, null, new Exception("You are me!"));
} else {
SubringEdge se = new SubringEdge(_local_ta, sta, false,
new AHExactSender(_shared_node, sta.Target), _ptype);
se.CloseEvent += CloseHandler;
_it.Add(se);
ecb(true, se, null);
}
}
开发者ID:pstjuste,项目名称:brunet,代码行数:18,代码来源:SubringEdgeListener.cs
示例12: Test
public void Test()
{
SimulationTransportAddress.Enable();
SimulationTransportAddressOther.Enable();
var ta = TransportAddressFactory.CreateInstance("b.s://234580") as SimulationTransportAddress;
var tai = ta.Invert();
TransportAddress[] tas = new TransportAddress[2] { tai, ta };
var ta_oth = TransportAddressFactory.CreateInstance("b.s://234581");
var ta_oth0 = TransportAddressFactory.CreateInstance("b.s://234582");
var nat = new RestrictedConeNat(ta, 30000);
Assert.IsFalse(nat.Incoming(ta_oth), "No outbound yet...");
Assert.IsTrue(nat.Outgoing(ta_oth), "outbound...");
Assert.IsFalse(nat.AllowingIncomingConnections, "Have not received external ta.");
Assert.AreEqual(nat.InternalTransportAddresses, nat.KnownTransportAddresses, "ITA and KTA match");
nat.UpdateTAs(ta_oth, ta);
Assert.IsTrue(nat.Incoming(ta_oth), "Allowed incoming");
Assert.IsFalse(nat.Incoming(ta_oth0), "Port mapped systems must send out a packet first...");
Assert.IsTrue(nat.AllowingIncomingConnections, "Have received external ta.");
Assert.AreEqual(tas, nat.KnownTransportAddresses, "Two TAs!");
Assert.IsTrue(nat.Outgoing(ta_oth0), "outbound...");
Brunet.Util.SimpleTimer.RunSteps(7500);
Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
Brunet.Util.SimpleTimer.RunSteps(7500);
Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
Brunet.Util.SimpleTimer.RunSteps(7500);
Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
Brunet.Util.SimpleTimer.RunSteps(7500);
Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
Assert.IsTrue(nat.AllowingIncomingConnections, "Have received external ta.");
Assert.AreEqual(tas, nat.KnownTransportAddresses, "Two TAs!");
Brunet.Util.SimpleTimer.RunSteps(60000);
Assert.IsFalse(nat.AllowingIncomingConnections, "AllowIC: Timed out...");
Assert.IsFalse(nat.Incoming(ta_oth), "Incoming: Timed out....");
}
开发者ID:pstjuste,项目名称:brunet,代码行数:37,代码来源:RestrictedConeNat.cs
示例13: IPTransportAddress
public IPTransportAddress(TransportAddress.TAType t, IPAddress addr, int port):
this(String.Format("brunet.{0}://{1}:{2}", TATypeToString(t), addr, port))
{
_type = t;
_ips = new ArrayList(1);
_ips.Add( addr );
}
开发者ID:johnynek,项目名称:brunet,代码行数:7,代码来源:TransportAddress.cs
示例14: Outgoing
public bool Outgoing(TransportAddress remote_ta)
{
return true;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:4,代码来源:PublicNat.cs
示例15: PublicNat
public PublicNat(TransportAddress local_ta)
{
_local_tas = new TransportAddress[1] { local_ta };
}
开发者ID:pstjuste,项目名称:brunet,代码行数:4,代码来源:PublicNat.cs
示例16: CreateEdgeTo
/**
* Implements the EdgeListener function to
* create edges of this type.
*/
public override void CreateEdgeTo(TransportAddress ta, EdgeCreationCallback ecb)
{
Edge e = null;
Exception ex = null;
if( !IsStarted ) {
ex = new EdgeException("UdpEdgeListener is not started");
} else if( ta.TransportAddressType != this.TAType ) {
ex = new EdgeException(ta.TransportAddressType.ToString()
+ " is not my type: " + this.TAType.ToString() );
} else if( _ta_auth.Authorize(ta) == TAAuthorizer.Decision.Deny ) {
ex = new EdgeException( ta.ToString() + " is not authorized");
} else {
IPAddress first_ip = ((IPTransportAddress) ta).GetIPAddress();
IPEndPoint end = new IPEndPoint(first_ip, ((IPTransportAddress) ta).Port);
/* We have to keep our mapping of end point to edges up to date */
lock( _id_ht ) {
//Get a random ID for this edge:
int id;
do {
id = _rand.Next();
//Make sure we don't have negative ids
if( id < 0 ) { id = ~id; }
} while( _id_ht.Contains(id) || id == 0 );
e = new UdpEdge(this, false, end, _local_ep, id, 0);
_id_ht[id] = e;
}
NatDataPoint dp = new NewEdgePoint(DateTime.UtcNow, e);
Interlocked.Exchange<NatHistory>(ref _nat_hist, _nat_hist + dp);
Interlocked.Exchange<IEnumerable>(ref _nat_tas, new NatTAs( _tas, _nat_hist ));
try {
/* Tell me when you close so I can clean up the table */
e.CloseEvent += this.CloseHandler;
} catch (Exception x) {
e = null;
ex = x;
}
}
if(e != null) {
ecb(true, e, null);
} else {
ecb(false, null, ex);
}
}
开发者ID:bakriy,项目名称:brunet,代码行数:49,代码来源:UdpEdgeListener.cs
示例17: CreateEdgeTo
/*
* Implements the EdgeListener function to
* create edges of this type.
*/
public override void CreateEdgeTo(TransportAddress ta,
EdgeCreationCallback ecb)
{
if( !IsStarted )
{
// it should return null and not throw an exception
// for graceful disconnect and preventing others to
// connect to us after we've disconnected.
ecb(false, null, new EdgeException("Not started"));
return;
}
if( ta.TransportAddressType != this.TAType ) {
//Can't make an edge of this type
ecb(false, null, new EdgeException("Can't make edge of this type"));
return;
}
if( _ta_auth.Authorize(ta) == TAAuthorizer.Decision.Deny ) {
//Not authorized. Can't make this edge:
ecb(false, null, new EdgeException( ta.ToString() + " is not authorized") );
return;
}
int remote_id = ((SimulationTransportAddress) ta).ID;
//Get the edgelistener:
//Outbound edge:
int delay = 0;
if(_use_delay) {
if(LatencyMap != null) {
// id != 0, so we reduce all by 1
delay = LatencyMap[_listener_id][remote_id] / 1000;
} else {
delay = 100;
}
}
SimulationEdge se_l = new SimulationEdge(this, _listener_id, remote_id, false, delay);
AddEdge(se_l);
SimulationEdgeListener remote = (SimulationEdgeListener) _listener_map[remote_id];
if( remote != null ) {
//
// Make sure that the remote listener does not deny
// our TAs.
//
foreach (TransportAddress ta_local in LocalTAs) {
if (remote.TAAuth.Authorize(ta_local) == TAAuthorizer.Decision.Deny ) {
//Not authorized. Can't make this edge:
ecb(false, null, new EdgeException( ta_local.ToString() + " is not authorized by remote node.") );
return;
}
}
SimulationEdge se_r = new SimulationEdge(remote, remote_id, _listener_id, true, delay);
remote.AddEdge(se_r);
se_l.Partner = se_r;
se_r.Partner = se_l;
remote.SendEdgeEvent(se_r);
} else {
//There is no other edge, for now, we use "udp-like"
//behavior of just making an edge that goes nowhere.
}
ecb(true, se_l, null);
}
开发者ID:bakriy,项目名称:brunet,代码行数:72,代码来源:SimulationEdgeListener.cs
示例18: UpdateLocalTAs
/**
* When a new Connection is added, we may need to update the list
* of TAs to make sure it is not too long, and that the it is sorted
* from most likely to least likely to be successful
* @param e the new Edge
* @param ta the TransportAddress our TA according to our peer
*/
public override void UpdateLocalTAs(Edge e, TransportAddress ta) {
if( e.TAType == this.TAType ) {
UdpEdge ue = (UdpEdge)e;
ue.PeerViewOfLocalTA = ta;
NatDataPoint dp = new LocalMappingChangePoint(DateTime.UtcNow, e, ta);
Interlocked.Exchange<NatHistory>(ref _nat_hist, _nat_hist + dp);
Interlocked.Exchange<IEnumerable>(ref _nat_tas, new NatTAs( _tas, _nat_hist ));
}
}
开发者ID:bakriy,项目名称:brunet,代码行数:16,代码来源:UdpEdgeListener.cs
示例19: SplitPath
/** return the base TransportAddress and the path associated with it
*/
public static TransportAddress SplitPath(TransportAddress ta, out string path) {
string tas = ta.ToString();
// Need to be careful of the case ta:////ta:9/
int init_idx = tas.IndexOf("://") + 3;
int idx = init_idx;
int pos = 0;
bool next = false;
for(; idx < tas.Length; idx++) {
if(tas[idx] == '/') {
if(!next) {
pos = idx;
}
} else {
next = false;
}
}
if(pos > 0) {
path = tas.Substring(pos);
return TransportAddressFactory.CreateInstance(tas.Substring(0, pos));
} else {
path = "/";
return ta;
}
}
开发者ID:hseom,项目名称:brunet,代码行数:27,代码来源:PathEdgeListener.cs
示例20: JoinPath
/** Join a path to the end of a TransportAddress
*/
public static TransportAddress JoinPath(TransportAddress ta, string path) {
Uri orig_u = ta.Uri;
string s = orig_u.ToString();
if( s[s.Length - 1] == '/' ) {
s = s.Substring(0, s.Length - 1);
}
if (path[0] == '/') {
path = path.Substring(1);
}
return TransportAddressFactory.CreateInstance(String.Format("{0}/{1}", s, path));
}
开发者ID:hseom,项目名称:brunet,代码行数:13,代码来源:PathEdgeListener.cs
注:本文中的Brunet.Transport.TransportAddress类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论