/// <summary> /// Event arguments for message events. /// </summary> /// <param name="e">Values are taken from this object.</param> public MessageEventArgs(MessageEventArgs e) { this.bodies = e.bodies; this.subjects = e.subjects; this.message = e.message; this.content = e.content; this.errorElement = e.errorElement; this.errorType = e.errorType; this.stanzaError = e.stanzaError; this.errorText = e.errorText; this.client = e.client; this.component = e.component; this.type = e.type; this.threadId = e.threadId; this.parentThreadId = e.parentThreadId; this.from = e.from; this.fromBareJid = e.fromBareJid; this.to = e.to; this.id = e.id; this.body = e.body; this.subject = e.subject; this.errorCode = e.errorCode; this.ok = e.ok; this.e2eEncryption = e.e2eEncryption; this.e2eReference = e.e2eReference; }
/// <summary> /// Event arguments for message events. /// </summary> /// <param name="e">Values are taken from this object.</param> public MessageEventArgs(MessageEventArgs e) { this.bodies = e?.bodies; this.subjects = e?.subjects; this.message = e?.message; this.content = e?.content; this.errorElement = e?.errorElement; this.errorType = e?.errorType ?? ErrorType.Undefined; this.stanzaError = e?.stanzaError; this.errorText = e?.errorText; this.client = e?.client; this.component = e?.component; this.type = e?.type ?? MessageType.Normal; this.threadId = e?.threadId; this.parentThreadId = e?.parentThreadId; this.from = e?.from; this.fromBareJid = e?.fromBareJid; this.to = e?.to; this.id = e?.id; this.body = e?.body; this.subject = e?.subject; this.errorCode = e?.errorCode ?? 0; this.ok = e?.ok ?? false; this.e2eEncryption = e?.e2eEncryption; this.e2eReference = e?.e2eReference; }
/// <summary> /// Class managing a SOCKS5 proxy associated with the current XMPP server. /// </summary> /// <param name="Client">XMPP Client.</param> /// <param name="E2E">End-to-end encryption interface.</param> public Socks5Proxy(XmppClient Client, IEndToEndEncryption E2E) : base(Client) { this.e2e = E2E; this.client.RegisterIqSetHandler("query", Namespace, this.QueryHandler, true); }
/// <summary> /// Provides help with managing avatars. /// </summary> /// <param name="Client">XMPP Client</param> /// <param name="PepClient">Personal Eventing Protocol Client</param> /// <param name="E2E">End-to-End encryption</param> public AvatarClient(XmppClient Client, PepClient PepClient, IEndToEndEncryption E2E) : base(Client) { this.pep = PepClient; this.e2e = E2E; // XEP-0008: IQ-Based Avatars: http://xmpp.org/extensions/xep-0008.html Client.RegisterIqGetHandler("query", "jabber:iq:avatar", this.QueryAvatarHandler, false); Client.OnStateChanged += Client_OnStateChanged; Client.OnPresence += Client_OnPresence; Client.OnRosterItemRemoved += Client_OnRosterItemRemoved; Client.OnRosterItemAdded += Client_OnRosterItemAdded; Client.CustomPresenceXml += Client_CustomPresenceXml; if (this.pep != null) { this.pep.OnUserAvatarMetaData += Pep_OnUserAvatarMetaData; } byte[] Bin = Resources.LoadResource(typeof(AvatarClient).Namespace + ".Images.DefaultAvatar.png", typeof(AvatarClient).GetTypeInfo().Assembly); this.defaultAvatar = new Avatar(Client.BareJID.ToLower(), "image/png", Bin, 64, 64); Task.Run(() => this.LoadAvatar()); }
/// <summary> /// HTTPX client. /// </summary> /// <param name="Client">XMPP Client.</param> /// <param name="E2e">End-to-end encryption interface.</param> /// <param name="MaxChunkSize">Max Chunk Size to use.</param> public HttpxClient(XmppClient Client, IEndToEndEncryption E2e, int MaxChunkSize) : base(Client) { this.e2e = E2e; this.maxChunkSize = MaxChunkSize; HttpxChunks.RegisterChunkReceiver(this.client); }
/// <summary> /// Event arguments for responses to IQ queries. /// </summary> /// <param name="E2eEncryption">End-to-end encryption algorithm used.</param> /// <param name="E2eReference">Reference to End-to-end encryption endpoint used.</param> /// <param name="E2eSymmetricCipher">Type of symmetric cipher used in E2E encryption.</param> /// <param name="Response">Response element.</param> /// <param name="Id">ID attribute.</param> /// <param name="To">To attribute.</param> /// <param name="From">From attribute.</param> /// <param name="Ok">If response is a proper response (true), or an error response (false).</param> /// <param name="State">State object passed in the original request.</param> public IqResultEventArgs(IEndToEndEncryption E2eEncryption, string E2eReference, IE2eSymmetricCipher E2eSymmetricCipher, XmlElement Response, string Id, string To, string From, bool Ok, object State) : this(Response, Id, To, From, Ok, State) { this.e2eEncryption = E2eEncryption; this.e2eReference = E2eReference; this.e2eSymmetricCipher = E2eSymmetricCipher; }
/// <summary> /// HTTPX client. /// </summary> /// <param name="Client">XMPP Client.</param> /// <param name="MaxChunkSize">Max Chunk Size to use.</param> public HttpxClient(XmppClient Client, int MaxChunkSize) : base(Client) { this.e2e = null; this.maxChunkSize = MaxChunkSize; HttpxChunks.RegisterChunkReceiver(this.client); }
/// <summary> /// Event arguments for IQ queries. /// </summary> /// <param name="Client">XMPP Client.</param> /// <param name="Iq">IQ element.</param> /// <param name="Id">Id attribute of IQ stanza.</param> /// <param name="To">To attribute of IQ stanza.</param> /// <param name="From">From attribute of IQ stanza.</param> public IqEventArgs(XmppClient Client, XmlElement Iq, string Id, string To, string From) { this.client = Client; this.component = null; this.e2eEncryption = null; this.iq = Iq; this.id = Id; this.to = To; this.from = From; }
/// <summary> /// Class managing the transmission of a SOCKS5 bytestream. /// </summary> /// <param name="Client">XMPP client.</param> /// <param name="To">To</param> /// <param name="BlockSize">Block size</param> /// <param name="E2E">End-to-end encryption, if used.</param> public OutgoingStream(XmppClient Client, string To, int BlockSize, IEndToEndEncryption E2E) { this.xmppClient = Client; this.client = null; this.to = To; this.blockSize = BlockSize; this.e2e = E2E; this.isWriting = false; this.done = false; this.tempFile = new TemporaryFile(); }
/// <summary> /// Class managing the transmission of a SOCKS5 bytestream. /// </summary> /// <param name="StreamId">Stream ID.</param> /// <param name="From">From</param> /// <param name="To">To</param> /// <param name="BlockSize">Block size</param> /// <param name="E2E">End-to-end encryption, if used.</param> public OutgoingStream(string StreamId, string From, string To, int BlockSize, IEndToEndEncryption E2E) { this.client = null; this.sid = StreamId; this.from = From; this.to = To; this.blockSize = BlockSize; this.e2e = E2E; this.isWriting = false; this.done = false; this.tempFile = new TemporaryFile(); }
/// <summary> /// Event arguments for IQ queries. /// </summary> /// <param name="Component">XMPP Component.</param> /// <param name="Iq">IQ element.</param> /// <param name="Id">Id attribute of IQ stanza.</param> /// <param name="To">To attribute of IQ stanza.</param> /// <param name="From">From attribute of IQ stanza.</param> public IqEventArgs(XmppComponent Component, XmlElement Iq, string Id, string To, string From) { this.client = null; this.component = Component; this.iq = Iq; this.id = Id; this.to = To; this.from = From; this.e2eEncryption = null; this.e2eReference = null; this.e2eSymmetricCipher = null; }
/// <summary> /// Event arguments for IQ queries. /// </summary> protected IqEventArgs(IqEventArgs e) { this.client = e.client; this.component = e.component; this.iq = e.iq; this.id = e.id; this.to = e.to; this.from = e.from; this.e2eEncryption = e.e2eEncryption; this.e2eReference = e.e2eReference; this.e2eSymmetricCipher = e.e2eSymmetricCipher; }
public HttpxResponse(XmppClient Client, IEndToEndEncryption E2e, string Id, string To, string From, int MaxChunkSize, InBandBytestreams.IbbClient IbbClient, P2P.SOCKS5.Socks5Proxy Socks5Proxy) : base() { this.client = Client; this.e2e = E2e; this.ibbClient = IbbClient; this.socks5Proxy = Socks5Proxy; this.id = Id; this.to = To; this.from = From; this.maxChunkSize = MaxChunkSize; }
internal OutgoingStream(XmppClient Client, string To, string StreamId, int BlockSize, IEndToEndEncryption E2E) { this.client = Client; this.streamId = StreamId; this.to = To; this.blockSize = BlockSize; this.e2e = E2E; this.isWriting = false; this.seq = 0; this.done = false; this.tempFile = new TemporaryFile(); }
/// <summary> /// Class managing the transmission of a SOCKS5 bytestream. /// </summary> /// <param name="StreamId">Stream ID.</param> /// <param name="From">From</param> /// <param name="To">To</param> /// <param name="BlockSize">Block size</param> /// <param name="E2E">End-to-end encryption, if used.</param> public OutgoingStream(string StreamId, string From, string To, int BlockSize, IEndToEndEncryption E2E) { this.client = null; this.sid = StreamId; this.from = From; this.to = To; this.blockSize = BlockSize; this.e2e = E2E; this.isWriting = false; this.done = false; this.tempStream = new TemporaryStream(); this.syncObject = new MultiReadSingleWriteObject(); }
/// <summary> /// Event arguments for IQ queries. /// </summary> /// <param name="Client">XMPP Client.</param> /// <param name="E2eEncryption">End-to-end encryption algorithm used.</param> /// <param name="E2eReference">Reference to End-to-end encryption endpoint used.</param> /// <param name="E2eSymmetricCipher">Type of symmetric cipher used in E2E encryption.</param> /// <param name="Iq">IQ element.</param> /// <param name="Id">Id attribute of IQ stanza.</param> /// <param name="To">To attribute of IQ stanza.</param> /// <param name="From">From attribute of IQ stanza.</param> public IqEventArgs(XmppClient Client, IEndToEndEncryption E2eEncryption, string E2eReference, IE2eSymmetricCipher E2eSymmetricCipher, XmlElement Iq, string Id, string To, string From) { this.client = Client; this.component = null; this.e2eEncryption = E2eEncryption; this.e2eReference = E2eReference; this.e2eSymmetricCipher = E2eSymmetricCipher; this.iq = Iq; this.id = Id; this.to = To; this.from = From; }
internal ServerChunkRecord(HttpxServer Server, string Id, string From, string To, HttpRequest Request, IEndToEndEncryption E2e, TemporaryFile File, int MaxChunkSize, bool Sipub, bool Ibb, bool Socks5, bool Jingle) : base() { this.server = Server; this.id = Id; this.from = From; this.to = To; this.request = Request; this.e2e = E2e; this.file = File; this.maxChunkSize = MaxChunkSize; this.sipub = Sipub; this.ibb = Ibb; this.s5 = Socks5; this.jingle = Jingle; }
/// <summary> /// Event arguments for responses to IQ queries. /// </summary> /// <param name="e">Values are taken from this object.</param> protected IqResultEventArgs(IqResultEventArgs e) { this.response = e.response; this.errorElement = e.errorElement; this.errorType = e.errorType; this.stanzaError = e.stanzaError; this.errorText = e.errorText; this.state = e.state; this.id = e.id; this.to = e.to; this.from = e.from; this.errorCode = e.errorCode; this.ok = e.ok; this.e2eEncryption = e.e2eEncryption; this.e2eReference = e.e2eReference; this.e2eSymmetricCipher = e.e2eSymmetricCipher; }
/// <summary> /// Opens a new binary stream. /// </summary> /// <param name="To">Recipient of stream.</param> /// <param name="BlockSize">Block size.</param> /// <param name="StreamId">Desired stream ID. If null or empty, one will be created.</param> /// <param name="E2E">End-to-end encryption interface, if such is to be used.</param> /// <returns>Outgoing stream.</returns> public OutgoingStream OpenStream(string To, int BlockSize, string StreamId, IEndToEndEncryption E2E) { if (string.IsNullOrEmpty(StreamId)) { StreamId = Hashes.BinaryToString(XmppClient.GetRandomBytes(16)); } OutgoingStream Result = new OutgoingStream(this.client, To, StreamId, BlockSize, E2E); StringBuilder Xml = new StringBuilder(); Xml.Append("<open xmlns='"); Xml.Append(Namespace); Xml.Append("' block-size='"); Xml.Append(BlockSize.ToString()); Xml.Append("' sid='"); Xml.Append(StreamId); Xml.Append("' stanza='iq'/>"); this.client.SendIqSet(To, Xml.ToString(), (sender, e) => { if (e.Ok) { Result.Opened(e); lock (this.output) { this.output[StreamId] = Result; } } else { Result.Abort(); } }, null); return(Result); }
internal async Task Process(string Id, string From, string To, HttpRequest Request, IEndToEndEncryption E2e, string EndpointReference, int MaxChunkSize, string PostResource, bool Ibb, bool Socks5) { HttpAuthenticationScheme[] AuthenticationSchemes; bool Result; try { if (this.server.TryGetResource(Request.Header.Resource, out HttpResource Resource, out string SubPath)) { Request.Resource = Resource; this.server.RequestReceived(Request, From, Resource, SubPath); AuthenticationSchemes = Resource.GetAuthenticationSchemes(Request); if (AuthenticationSchemes != null && AuthenticationSchemes.Length > 0) { foreach (HttpAuthenticationScheme Scheme in AuthenticationSchemes) { if (Scheme.UserSessions && Request.Session is null) { HttpFieldCookie Cookie = Request.Header.Cookie; if (!(Cookie is null)) { string HttpSessionID = Cookie["HttpSessionID"]; if (!string.IsNullOrEmpty(HttpSessionID)) { Request.Session = this.server.GetSession(HttpSessionID); } } } IUser User = await Scheme.IsAuthenticated(Request); if (!(User is null)) { Request.User = User; break; } } if (Request.User is null) { List <KeyValuePair <string, string> > Challenges = new List <KeyValuePair <string, string> >(); foreach (HttpAuthenticationScheme Scheme in AuthenticationSchemes) { string Challenge = Scheme.GetChallenge(); if (!string.IsNullOrEmpty(Challenge)) { Challenges.Add(new KeyValuePair <string, string>("WWW-Authenticate", Challenge)); } } await this.SendQuickResponse(Request, E2e, EndpointReference, Id, From, To, 401, "Unauthorized", false, MaxChunkSize, Challenges.ToArray()); Request.Dispose(); return; } } Request.SubPath = SubPath; Resource.Validate(Request); if (Request.Header.Expect != null) { if (Request.Header.Expect.Continue100) { if (!Request.HasData) { await this.SendQuickResponse(Request, E2e, EndpointReference, Id, From, To, 100, "Continue", false, MaxChunkSize); return; } } else { await this.SendQuickResponse(Request, E2e, EndpointReference, Id, From, To, 417, "Expectation Failed", true, MaxChunkSize); Request.Dispose(); return; } } await this.ExecuteRequest(E2e, EndpointReference, Id, From, To, MaxChunkSize, PostResource, Ibb, Socks5, Request, Resource); return; } else { this.server.RequestReceived(Request, From, null, null); await this.SendQuickResponse(Request, E2e, EndpointReference, Id, From, To, 404, "Not Found", false, MaxChunkSize); Result = true; } }
/// <summary> /// Opens a new binary stream. /// </summary> /// <param name="To">Recipient of stream.</param> /// <param name="BlockSize">Block size.</param> /// <param name="E2E">End-to-end encryption interface, if such is to be used.</param> /// <returns>Outgoing stream.</returns> public OutgoingStream OpenStream(string To, int BlockSize, IEndToEndEncryption E2E) { return(this.OpenStream(To, BlockSize, null, E2E)); }
internal void Process(string Id, string From, string To, HttpRequest Request, IEndToEndEncryption E2e, string EndpointReference, int MaxChunkSize, bool Sipub, bool Ibb, bool Socks5, bool Jingle) { HttpAuthenticationScheme[] AuthenticationSchemes; bool Result; try { if (this.server.TryGetResource(Request.Header.Resource, out HttpResource Resource, out string SubPath)) { Request.Resource = Resource; this.server.RequestReceived(Request, From, Resource, SubPath); AuthenticationSchemes = Resource.GetAuthenticationSchemes(Request); if (AuthenticationSchemes != null && AuthenticationSchemes.Length > 0) { foreach (HttpAuthenticationScheme Scheme in AuthenticationSchemes) { if (Scheme.IsAuthenticated(Request, out IUser User)) { Request.User = User; break; } } if (Request.User is null) { List <KeyValuePair <string, string> > Challenges = new List <KeyValuePair <string, string> >(); foreach (HttpAuthenticationScheme Scheme in AuthenticationSchemes) { Challenges.Add(new KeyValuePair <string, string>("WWW-Authenticate", Scheme.GetChallenge())); } this.SendQuickResponse(Request, E2e, EndpointReference, Id, From, To, 401, "Unauthorized", false, MaxChunkSize, Challenges.ToArray()); Request.Dispose(); return; } } Request.SubPath = SubPath; Resource.Validate(Request); if (Request.Header.Expect != null) { if (Request.Header.Expect.Continue100) { if (!Request.HasData) { this.SendQuickResponse(Request, E2e, EndpointReference, Id, From, To, 100, "Continue", false, MaxChunkSize); return; } } else { this.SendQuickResponse(Request, E2e, EndpointReference, Id, From, To, 417, "Expectation Failed", true, MaxChunkSize); Request.Dispose(); return; } } this.ExecuteRequest(E2e, EndpointReference, Id, From, To, MaxChunkSize, Ibb, Socks5, Request, Resource); return; } else { this.server.RequestReceived(Request, From, null, null); this.SendQuickResponse(Request, E2e, EndpointReference, Id, From, To, 404, "Not Found", false, MaxChunkSize); Result = true; } }
/// <summary> /// Provides help with managing avatars. /// </summary> /// <param name="Client">XMPP Client</param> /// <param name="E2E">End-to-End encryption</param> public AvatarClient(XmppClient Client, IEndToEndEncryption E2E) : this(Client, null, E2E) { }