📄 passwordmethodsocks5message.cs
字号:
namespace Imps.Client.CommLayer.SocksSipConnection
{
using System;
using System.IO;
using System.Text;
internal sealed class PasswordMethodSocks5Message : Socks5Message
{
private string _password;
private string _userName;
public PasswordMethodSocks5Message()
{
this._userName = string.Empty;
this._password = string.Empty;
}
public PasswordMethodSocks5Message(string username, string password)
{
this._userName = string.Empty;
this._password = string.Empty;
this.UserName = username;
this.Password = password;
}
public override byte[] ToBinary()
{
MemoryStream stream = new MemoryStream();
stream.WriteByte(1);
stream.WriteByte((byte) this.UserName.Length);
byte[] bytes = Encoding.UTF8.GetBytes(this.UserName);
stream.Write(bytes, 0, bytes.Length);
stream.WriteByte((byte) this.Password.Length);
bytes = Encoding.UTF8.GetBytes(this.Password);
stream.Write(bytes, 0, bytes.Length);
return stream.ToArray();
}
public override string ToString()
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat("VER{0}\n", base.Ver);
builder.AppendFormat("METHOD : PasswordAuthType({0})\n", SocksMethod.Password);
builder.AppendFormat("USERNAME : {0}\n", this.UserName);
builder.AppendFormat("PASSWORD : {0}", this.Password);
return builder.ToString();
}
public string Password
{
get
{
return this._password;
}
set
{
if (value == null)
{
throw new ArgumentNullException("Password");
}
this._password = value;
}
}
public string UserName
{
get
{
return this._userName;
}
set
{
if (value == null)
{
throw new ArgumentNullException("UserName");
}
this._userName = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -