コード例 #1
0
            public void WriteTo(Stream s)
            {
                BincodingEncoder encoder = new BincodingEncoder(s, "FI", 2);

                if (_filePath != null)
                {
                    encoder.Encode("file_path", _filePath);
                }

                encoder.Encode("file_metadata", _fileMetaData);
                encoder.Encode("state", (byte)_state);
                encoder.Encode("block_available", _blockAvailable);

                //signal end
                encoder.EncodeNull();
            }
コード例 #2
0
            public void WriteTo(Stream s)
            {
                BincodingEncoder encoder = new BincodingEncoder(s, "BI", 7);

                encoder.Encode("type", (byte)_type);

                if (_networkNameOrPeerEmailAddress != null)
                {
                    encoder.Encode("network_name", _networkNameOrPeerEmailAddress);
                }

                if (_sharedSecret != null)
                {
                    encoder.Encode("shared_secret", _sharedSecret);
                }

                encoder.Encode("enable_tracking", _enableTracking);
                encoder.Encode("send_invitation", _sendInvitation);

                if (_invitationSender != null)
                {
                    encoder.Encode("invitation_sender", _invitationSender);
                }

                if (_invitationMessage != null)
                {
                    encoder.Encode("invitation_message", _invitationMessage);
                }

                encoder.Encode("network_status", (byte)_networkStatus);

                if (_hashedPeerEmailAddress != null)
                {
                    encoder.Encode("hashed_peer_email_address", _hashedPeerEmailAddress.Number);
                }

                if (_networkID != null)
                {
                    encoder.Encode("network_id", _networkID.Number);
                }

                if (_networkSecret != null)
                {
                    encoder.Encode("network_secret", _networkSecret.Number);
                }

                encoder.Encode("message_store_id", _messageStoreID);
                encoder.Encode("message_store_key", _messageStoreKey);

                encoder.Encode("group_image_date_modified", _groupImageDateModified);
                if (_groupImage != null)
                {
                    encoder.Encode("group_image", _groupImage);
                }

                encoder.Encode("mute", _mute);

                encoder.Encode("peer_certs", _peerCerts);
                encoder.Encode("shared_files", _sharedFiles);

                {
                    List <Bincoding> trackerList = new List <Bincoding>(_sharedFiles.Length);

                    foreach (Uri trackerURI in _trackerURIs)
                    {
                        trackerList.Add(Bincoding.GetValue(trackerURI.AbsoluteUri));
                    }

                    encoder.Encode("tracker_list", trackerList);
                }

                //signal end of settings
                encoder.EncodeNull();
            }
コード例 #3
0
        protected override void WritePlainTextTo(Stream s)
        {
            BincodingEncoder encoder = new BincodingEncoder(s, "BP", 7);

            //main settings

            //bitchat local port
            encoder.Encode("local_port", _localPort);

            //check CertificateRevocationList
            encoder.Encode("check_cert_revocation", _checkCertificateRevocationList);

            //upnp enabled
            encoder.Encode("enable_upnp", _enableUPnP);

            //enable invitation
            encoder.Encode("allow_inbound_invitations", _allowInboundInvitations);
            encoder.Encode("allow_only_local_inbound_invitations", _allowOnlyLocalInboundInvitations);

            //download folder
            if (_downloadFolder != null)
            {
                encoder.Encode("download_folder", _downloadFolder);
            }

            //local cert store
            if (_localCertStore != null)
            {
                encoder.Encode("local_cert_store", _localCertStore);
            }

            //profile image
            encoder.Encode("profile_image_date_modified", _profileImageDateModified);

            if (_profileImage != null)
            {
                encoder.Encode("profile_image", _profileImage);
            }

            //tracker urls
            {
                List <Bincoding> trackerList = new List <Bincoding>(_trackerURIs.Length);

                foreach (Uri trackerURI in _trackerURIs)
                {
                    trackerList.Add(Bincoding.GetValue(trackerURI.AbsoluteUri));
                }

                encoder.Encode("tracker_list", trackerList);
            }

            //bitchat info
            {
                List <Bincoding> bitChatInfoList = new List <Bincoding>(_bitChatInfoList.Length);

                foreach (BitChatInfo info in _bitChatInfoList)
                {
                    bitChatInfoList.Add(Bincoding.GetValue(info));
                }

                encoder.Encode("bitchat_info", bitChatInfoList);
            }

            //bootstrap dht nodes
            {
                List <Bincoding> dhtNodeList = new List <Bincoding>(_bootstrapDhtNodes.Length);

                using (MemoryStream mS = new MemoryStream())
                {
                    foreach (IPEndPoint nodeEP in _bootstrapDhtNodes)
                    {
                        mS.SetLength(0);
                        IPEndPointParser.WriteTo(nodeEP, mS);

                        dhtNodeList.Add(Bincoding.GetValue(mS.ToArray()));
                    }
                }

                encoder.Encode("dht_nodes", dhtNodeList);
            }

            //proxy settings

            //proxy type
            if (_proxy != null)
            {
                encoder.Encode("proxy_type", (byte)_proxy.Type);
            }

            //proxy address
            if (_proxyAddress != null)
            {
                encoder.Encode("proxy_address", _proxyAddress);
            }

            //proxy port
            encoder.Encode("proxy_port", _proxyPort);

            //proxy credentials
            if (_proxyCredentials != null)
            {
                encoder.Encode("proxy_user", _proxyCredentials.UserName);
                encoder.Encode("proxy_pass", _proxyCredentials.Password);
            }

            //generic client data
            if ((_clientData != null) && (_clientData.Length > 0))
            {
                encoder.Encode("client_data", _clientData);
            }

            //signal end of settings
            encoder.EncodeNull();
        }