GrassWebProxy

GrassWebProxy第一版:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using System.Net.Http;
using System.Runtime.InteropServices.ComTypes;namespace GrassWebProxy
{public class Ticket{public ulong TicketNo { get; set; }public string BeginDateTime {  get; set; }public string EndDateTime { get; set; }}public class GP{public static bool CheckFlag(ref byte[] msg){//"G" 71 0x47//"P" 80 0x50if (msg[0]==0x47 && msg[1]==0x50){Console.WriteLine("CheckFlag OK");return true;}return false;}static public Ticket ReadConfig(string cfg = "Ticket1.json"){// 读取文件内容  string jsonContent = File.ReadAllText(cfg);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo}\r\n{ticket.BeginDateTime}---{ticket.EndDateTime}");return ticket;}static public bool CheckTicket(ref byte[] msg, Ticket counterfoil){ulong ticket = (ulong)((msg[2]<< 56) | (msg[3] << 48) | (msg[4] << 40)| (msg[5] << 32) | (msg[6] << 24) | (msg[7] <<16)|(msg[8] <<8)|msg[9]);Console.WriteLine(ticket.ToString("X"));if(counterfoil.TicketNo==ticket){return true;}return false;}}class TcpServer{private TcpListener tcpListener;private Thread listenThread;public TcpServer(string ipAddress, int port){this.tcpListener = new TcpListener(IPAddress.Parse(ipAddress), port);this.listenThread = new Thread(new ThreadStart(ListenForClients));this.listenThread.Start();}private void ListenForClients(){this.tcpListener.Start();while (true){// 阻塞直到客户端连接  TcpClient client = this.tcpListener.AcceptTcpClient();// 创建一个新的线程来处理客户端通信  Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientComm));clientThread.Start(client);}}/// <summary>/// 注意接受缓存只有4096字节。/// </summary>/// <param name="client"></param>private async void HandleClientComm(object client){TcpClient tcpClient = (TcpClient)client;NetworkStream clientStream = tcpClient.GetStream();//GuestIP.RecordIpToDatabase(tcpClient);byte[] message = new byte[8192];int bytesRead;while (true){bytesRead = 0;try{// 阻塞直到客户端发送数据  bytesRead = clientStream.Read(message, 0, message.Length);if (bytesRead == 0){// 客户端关闭了连接  break;}Console.WriteLine($"Read Bytes:{bytesRead}");}catch{// 客户端断开了连接  break;}try{//Checkif (GP.CheckFlag(ref message) == true && bytesRead >= 10){Console.WriteLine("GrassWebProxy应用来访");//Check Ticketif(GP.CheckTicket(ref message,GP.ReadConfig("Ticket1.json"))==true){Console.WriteLine("检票完成");var data = new string(Encoding.UTF8.GetChars(message, 10, bytesRead-10));Console.WriteLine(data);using (var httpClient = new HttpClient()){// 注意:这里需要处理完整的HTTP请求,包括头部和正文  // 这里仅作为示例,我们实际上并没有发送整个请求  var response = await httpClient.GetAsync(data);var responseContent = await response.Content.ReadAsStringAsync();Console.WriteLine(responseContent);// 将响应写回客户端  var responseBytes = Encoding.UTF8.GetBytes(responseContent);await clientStream.WriteAsync(responseBytes, 0, responseBytes.Length);Console.WriteLine("Send {0} Bytes.", responseBytes.Length);}}goto End;}}catch (Exception ex){Console.WriteLine($"{ex.Message}");}// 将接收到的数据回显给客户端  ASCIIEncoding encoder = new ASCIIEncoding();string messageString = encoder.GetString(message, 0, bytesRead);Console.WriteLine("Received from client: " + messageString);byte[] buffer = encoder.GetBytes(messageString);// 发送回显数据给客户端  clientStream.Write(buffer, 0, buffer.Length);clientStream.Flush();End://    //查看来访IP信息//    GuestIP.ReadLastGuestIP();;}tcpClient.Close();}}internal class Program{static void Main(string[] args){const int port = 8422;TcpServer server = new TcpServer("127.0.0.1", port);Console.WriteLine($"TCP Server listening on port {port}...");// 阻止主线程结束,直到用户手动停止  Console.ReadLine();}}
}
Ticket1.json 文件内容:
{"TicketNo":1,"BeginDateTime": "20240728T20:30:30","EndDateTime": "20240731T20:30:30"
}

GrassWebProxyV2:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using System.Net;
using System.Net.Http;namespace GrassWebProxyV2
{public class Ticket{public ulong TicketNo { get; set; }public string BeginDateTime { get; set; }public string EndDateTime { get; set; }}public class GP{public static bool CheckFlag(ref byte[] msg){//"G" 71 0x47//"P" 80 0x50if (msg[0] == 0x47 && msg[1] == 0x50){Console.WriteLine("CheckFlag OK");return true;}return false;}static public Ticket ReadConfig(string cfg = "Ticket1.json"){// 读取文件内容  string jsonContent = File.ReadAllText(cfg);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo}\r\n{ticket.BeginDateTime}---{ticket.EndDateTime}");return ticket;}static public bool CheckTicket(ref byte[] msg, Ticket counterfoil){/*ulong ticket = (ulong)((msg[2] << 56) | (msg[3] << 48) | (msg[4] << 40)| (msg[5] << 32) | (msg[6] << 24) | (msg[7] << 16) | (msg[8] << 8) | msg[9]);*/ulong ticket = BitConverter.ToUInt64(msg, 2); // 从索引2开始读取8个字节//Console.WriteLine(ticket.ToString("X"));if (counterfoil.TicketNo == ticket){return true;}return false;}static public bool CheckFlagAdTicket(ref byte[] msg, Ticket counterfoil){//"G" 71 0x47//"P" 80 0x50ulong ticket = BitConverter.ToUInt64(msg, 2); // 从索引2开始读取8个字节if (msg[0] == 0x47 && msg[1] == 0x50 && counterfoil.TicketNo == ticket){return true;}return false;}}class SimpleWebProxy{private HttpListener listener;public SimpleWebProxy(int port){// 初始化HttpListener,监听所有传入HTTP请求  listener = new HttpListener();listener.Prefixes.Add($"http://+:{port}/");listener.Start();Console.WriteLine($"Grass Web proxy listening on port {port}...");// 开始异步处理请求  Task.Run(() => ListenForRequests());}private async Task ListenForRequests(){while (true){// 等待并获取下一个客户端连接  HttpListenerContext context = await listener.GetContextAsync();HttpListenerRequest request = context.Request;假设Ticket存储在HTTP头中,名为"X-Proxy-Ticket"  string ticketHeader = request.Headers["X-Proxy-Ticket"];// 假设您有一个方法CheckTicket(string ticket)来验证ticket  // return CheckTicket(ticketHeader); // 这里应该是您的验证逻辑  // 为了示例,我们直接返回true或false(这里总是返回false以模拟验证失败)// 使用UTF8编码将字符串转换为byte[]  byte[] ticketBytes = Encoding.UTF8.GetBytes(ticketHeader);var counterfoil = GP.ReadConfig("Ticket1.json");if(GP.CheckFlagAdTicket(ref ticketBytes, counterfoil)==true){// 获取请求的URL(不包含查询字符串)  string url = request.Url.Scheme + "://" + request.Url.Host + ":" + request.Url.Port + request.Url.AbsolutePath;Console.WriteLine(url);// 创建一个WebRequest到目标URL  HttpWebRequest proxyRequest = (HttpWebRequest)WebRequest.Create(url);// 复制请求方法(如GET、POST)  proxyRequest.Method = request.HttpMethod;// 如果需要,可以添加更多的请求头(这里未添加)  // 发送请求到目标服务器并获取响应  using (HttpWebResponse proxyResponse = (HttpWebResponse)await proxyRequest.GetResponseAsync()){// 将响应转发给客户端  using (Stream responseStream = proxyResponse.GetResponseStream())using (Stream outputStream = context.Response.OutputStream){// 设置响应的HTTP状态码和状态描述  context.Response.StatusCode = (int)proxyResponse.StatusCode;context.Response.StatusDescription = proxyResponse.StatusDescription;// 遍历所有响应头并复制到响应中  foreach (string headerKey in proxyResponse.Headers.AllKeys){if (headerKey != "Transfer-Encoding" &&!(context.Response.Headers.AllKeys.Contains(headerKey))){context.Response.AddHeader(headerKey, proxyResponse.Headers[headerKey]);}}// 读取响应流并将其写入客户端的输出流  byte[] buffer = new byte[4096];int bytesRead;while ((bytesRead = await responseStream.ReadAsync(buffer, 0, buffer.Length)) > 0){await outputStream.WriteAsync(buffer, 0, bytesRead);}}}}else{// 票据验证失败,可以发送错误响应给客户端  context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;context.Response.Close();}}}}internal class Program{static void Main(string[] args){new SimpleWebProxy(8422);// 防止主线程退出  Console.WriteLine("Press Enter to exit...");Console.ReadLine();}}
}

GrassWebProxyV4:

// See https://aka.ms/new-console-template for more information
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Net.Http;
using System.Runtime.InteropServices.ComTypes;
using System.IO.Compression;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Runtime.Serialization;namespace GrassWebProxy
{public class CustomDateTimeConverter : IsoDateTimeConverter{public CustomDateTimeConverter(){DateTimeFormat = "yyyyMMdd'T'HH:mm:ss";}}public class Ticket{public ulong TicketNo { get; set; }[JsonConverter(typeof(CustomDateTimeConverter))]public DateTime BeginDateTime { get; set; }[JsonConverter(typeof(CustomDateTimeConverter))]public DateTime EndDateTime { get; set; }}public class GP{public static bool CheckFlag(ref byte[] msg){//"G" 71 0x47//"P" 80 0x50if (msg[0] == 0x47 && msg[1] == 0x50){Console.WriteLine("CheckFlag OK");return true;}return false;}static public Ticket ReadConfig(string cfg = "Ticket1.json"){// 读取文件内容  string jsonContent = File.ReadAllText(cfg);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo}\r\n{ticket.BeginDateTime}---{ticket.EndDateTime}");return ticket;}static public bool CheckTicket(ref byte[] msg, Ticket counterfoil){ulong ticket = (ulong)((msg[2] << 56) | (msg[3] << 48) | (msg[4] << 40)| (msg[5] << 32) | (msg[6] << 24) | (msg[7] << 16) | (msg[8] << 8) | msg[9]);Console.WriteLine(ticket.ToString("X"));if (counterfoil.TicketNo == ticket){return true;}return false;}public static byte[] Compress(byte[] input){using (var memoryStream = new MemoryStream()){using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, true)){gzipStream.Write(input, 0, input.Length);}// 确保所有数据都被写入并压缩  return memoryStream.ToArray();}}public static byte[] DecompressGzip(byte[] gzip, int prebytes = 4096){using (var ms = new MemoryStream(gzip)){using (var gzipStream = new GZipStream(ms, CompressionMode.Decompress)){var buffer = new byte[prebytes];using (var memoryStreamOut = new MemoryStream()){int read;while ((read = gzipStream.Read(buffer, 0, buffer.Length)) > 0){memoryStreamOut.Write(buffer, 0, read);}return memoryStreamOut.ToArray();}}}}}class TcpServer{private TcpListener tcpListener;private Thread listenThread;public TcpServer(string ipAddress, int port){this.tcpListener = new TcpListener(IPAddress.Parse(ipAddress), port);this.listenThread = new Thread(new ThreadStart(ListenForClients));this.listenThread.Start();}private void ListenForClients(){this.tcpListener.Start();while (true){// 阻塞直到客户端连接  TcpClient client = this.tcpListener.AcceptTcpClient();// 创建一个新的线程来处理客户端通信  Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientComm));clientThread.Start(client);}}/// <summary>/// 注意接受缓存只有4096字节。/// </summary>/// <param name="client"></param>private async void HandleClientComm(object client){TcpClient tcpClient = (TcpClient)client;NetworkStream clientStream = tcpClient.GetStream();//GuestIP.RecordIpToDatabase(tcpClient);byte[] message = new byte[8192];int bytesRead;while (true){bytesRead = 0;try{// 阻塞直到客户端发送数据  bytesRead = clientStream.Read(message, 0, message.Length);if (bytesRead == 0){// 客户端关闭了连接  break;}Console.WriteLine($"Read Bytes:{bytesRead}");}catch{// 客户端断开了连接  break;}try{//Checkif (GP.CheckFlag(ref message) == true && bytesRead >= 10){Console.WriteLine("GrassWebProxy应用来访");//Check Ticketif (GP.CheckTicket(ref message, GP.ReadConfig("Ticket1.json")) == true){Console.WriteLine("检票完成");var data = new string(Encoding.UTF8.GetChars(message, 10, bytesRead - 10));Console.WriteLine(data);using (var httpClient = new HttpClient()){// 注意:这里需要处理完整的HTTP请求,包括头部和正文  // 这里仅作为示例,我们实际上并没有发送整个请求  var response = await httpClient.GetAsync(data);var responseContent = await response.Content.ReadAsStringAsync();Console.WriteLine(responseContent);// 将响应写回客户端  //var responseBytes = Encoding.UTF8.GetBytes(responseContent);var rsbuf = await response.Content.ReadAsByteArrayAsync();Console.WriteLine(rsbuf.Length);var gzipbuf = GP.Compress(rsbuf);Console.WriteLine(gzipbuf.Length);await clientStream.WriteAsync(gzipbuf, 0, gzipbuf.Length);Console.WriteLine("Send {0} Bytes.", gzipbuf.Length);clientStream.Flush();Console.WriteLine("END");tcpClient.Close();}}goto End;}}catch (Exception ex){Console.WriteLine($"{ex.Message}");}// 将接收到的数据回显给客户端  ASCIIEncoding encoder = new ASCIIEncoding();string messageString = encoder.GetString(message, 0, bytesRead);Console.WriteLine("Received from client: " + messageString);byte[] buffer = encoder.GetBytes(messageString);// 发送回显数据给客户端  clientStream.Write(buffer, 0, buffer.Length);clientStream.Flush();Console.WriteLine("END");tcpClient.Close();End://    //查看来访IP信息//    GuestIP.ReadLastGuestIP();;}}}internal class Program{static void Main(string[] args){const int port = 8422;TcpServer server = new TcpServer("127.0.0.1", port);Console.WriteLine($"TCP Server listening on port {port}...");// 阻止主线程结束,直到用户手动停止  Console.ReadLine();}}
}

GrassWebProxyClient:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using System.Net.Http;
using System.Net;
using System.Net.Sockets;namespace GrassWebProxyClient
{public class IPport{public string IP { get; set; }public int Port { get; set; }}public class Ticket{public ulong TicketNo { get; set; }public string BeginDateTime { get; set; }public string EndDateTime { get; set; }}internal class Program{static void Main(string[] args){try{string jsonFilePath = "ipport.json"; // 替换为你的JSON文件路径  // 读取文件内容  string jsonContent = File.ReadAllText(jsonFilePath);// 反序列化JSON字符串到对象  IPport ipaddr = JsonConvert.DeserializeObject<IPport>(jsonContent);// 输出结果  Console.WriteLine($"{ipaddr.IP}:{ipaddr.Port}");// 创建一个TcpClient实例并连接到服务器  TcpClient client = new TcpClient($"{ipaddr.IP}", ipaddr.Port);// 获取一个NetworkStream对象以进行读写  NetworkStream stream = client.GetStream();jsonFilePath = "Ticket1.json";// 读取文件内容  jsonContent = File.ReadAllText(jsonFilePath);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo}\r\n{ticket.BeginDateTime}---{ticket.EndDateTime}");//组装byte[] data = { 0x47, 0x50, 0x01, 0xF2, 0x00, 0x00, 0x00, 0x01,0x01,0x01 };for (int i=2,j=7;i<data.Length;i++,j--){data[i] = (byte)(ticket.TicketNo>>(j*8));//Console.WriteLine(data[i]);}// 发送消息到服务器  stream.Write(data, 0, data.Length);// 发送消息到服务器// 将消息转换为字节数组  string message = "http://www.cjors.cn/";byte[] requestdata = Encoding.UTF8.GetBytes(message);// 将 data 和 requestdata 合并到 buffer 中  byte[] buffer = new byte[data.Length + requestdata.Length];Buffer.BlockCopy(data, 0, buffer, 0, data.Length);Buffer.BlockCopy(requestdata, 0, buffer, data.Length, requestdata.Length);stream.Write(requestdata, 0, requestdata.Length);// 读取服务器的响应  byte[] buf = new byte[8192];int bytesRead = stream.Read(buf, 0, buf.Length);// 将接收到的字节转换为字符串  string responseData = Encoding.UTF8.GetString(buf, 0, bytesRead);Console.WriteLine("Received from server: " + responseData);Console.WriteLine("ReceivedBytes:{0}", bytesRead);//将Json写入文件File.WriteAllText("response.html", responseData);// 关闭连接  client.Close();}catch (Exception e){Console.WriteLine("Error: " + e.Message);}// 等待用户按键,以便在控制台中查看结果  Console.WriteLine("Press Enter to continue...");Console.ReadLine();}}
}

GrassWebProxyClientV2:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using System.Net.Sockets;
using Newtonsoft.Json;
using System.Security.Policy;namespace GrassWebProxyClientV2
{public class IPport{public string IP { get; set; }public int Port { get; set; }}public class CpolarInfo{public int total { get; set; }public item[] items { get; set; }}public class item{public string name { get; set; }public string create_datetime { get; set; }public string pubulic_url { get; set; }}public class Ticket{public ulong TicketNo { get; set; }public string BeginDateTime { get; set; }public string EndDateTime { get; set; }}internal class Program{static void GetCploarInfo(){try{string jsonFilePath = "ipport.json"; // 替换为你的JSON文件路径  // 读取文件内容  string jsonContent = File.ReadAllText(jsonFilePath);// 反序列化JSON字符串到对象  IPport ipaddr = JsonConvert.DeserializeObject<IPport>(jsonContent);// 输出结果  Console.WriteLine($"{ipaddr.IP}:{ipaddr.Port}");// 创建一个TcpClient实例并连接到服务器  TcpClient client = new TcpClient($"{ipaddr.IP}", ipaddr.Port);// 获取一个NetworkStream对象以进行读写  NetworkStream stream = client.GetStream();// 将消息转换为字节数组  //string message = "Hello from the client!";//byte[] data = Encoding.ASCII.GetBytes(message);byte[] data = { 0x4E, 0x74, 0x01, 0xF2, 0x00, 0x00, 0x00, 0x01 };// 发送消息到服务器  stream.Write(data, 0, data.Length);// 读取服务器的响应  byte[] buffer = new byte[4096];int bytesRead = stream.Read(buffer, 0, buffer.Length);// 将接收到的字节转换为字符串  string responseData = Encoding.ASCII.GetString(buffer, 0, bytesRead);Console.WriteLine("Received from server: " + responseData);Console.WriteLine("ReceivedBytes:{0}", bytesRead);// 关闭连接  client.Close();//将Json写入文件File.WriteAllText("cpolarinfo.json", responseData);}catch (Exception e){Console.WriteLine("Error: " + e.Message);}}static void UseWebProxy(string webProxyUrl,string ip,int port){try{// 创建一个TcpClient实例并连接到服务器  TcpClient client = new TcpClient(ip, port);// 获取一个NetworkStream对象以进行读写  NetworkStream stream = client.GetStream();string jsonFilePath = "Ticket1.json";// 读取文件内容  string jsonContent = File.ReadAllText(jsonFilePath);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo}\r\n{ticket.BeginDateTime}---{ticket.EndDateTime}");//组装byte[] data = { 0x47, 0x50, 0x01, 0xF2, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01 };for (int i = 2, j = 7; i < data.Length; i++, j--){data[i] = (byte)(ticket.TicketNo >> (j * 8));//Console.WriteLine(data[i]);}// 将消息转换为字节数组  // 将 data 和 requestdata 合并到 buffer 中  byte[] requestdata = Encoding.UTF8.GetBytes(webProxyUrl);byte[] buf = new byte[data.Length + requestdata.Length];Buffer.BlockCopy(data, 0, buf, 0, data.Length);Buffer.BlockCopy(requestdata, 0, buf, data.Length, requestdata.Length);// 发送消息到服务器stream.Write(buf, 0, buf.Length);// 读取服务器的响应  byte[] buffer = new byte[81920];//int bytesRead = stream.Read(buffer, 0, buffer.Length);int totalBytesRead = 0;int bytesRead = 0;string responseData = string.Empty;while ((bytesRead = stream.Read(buffer, totalBytesRead, buffer.Length - totalBytesRead)) > 0){// 将接收到的字节转换为字符串  responseData = Encoding.UTF8.GetString(buffer, 0, bytesRead);Console.WriteLine("Received from server: " + responseData);Console.WriteLine("ReceivedBytes:{0}", bytesRead);totalBytesRead += bytesRead;// 可以在这里处理已经读取的数据(例如,写入文件或进行其他处理)  // 但请注意,如果处理逻辑复杂,最好先将数据复制到另一个缓冲区中  }// 现在 totalBytesRead 包含了从流中读取的总字节数Console.WriteLine("TotalReceivedBytes:{0}", totalBytesRead);//将Json写入文件File.WriteAllText("response.html", responseData);// 关闭连接  client.Close();}catch (Exception e){Console.WriteLine("Error: " + e.Message);}
}static void Main(string[] args){Console.WriteLine("请求Cploar动态域名和端口信息......");GetCploarInfo();string jsonContent=File.ReadAllText("cpolarinfo.json");Console.WriteLine(jsonContent);CpolarInfo cpinfo = JsonConvert.DeserializeObject<CpolarInfo>(jsonContent);Console.WriteLine($"{cpinfo.total}");for (int i = 0;i<cpinfo.total;i++){Console.WriteLine($"{cpinfo.items[i].name}\r\n{cpinfo.items[i].create_datetime}\r\n{cpinfo.items[i].pubulic_url}");}string host = string.Empty;for (int i = 0; i < cpinfo.total; i++){if (cpinfo.items[i].name== "GrassWebProxy"){host = cpinfo.items[i].pubulic_url;}}Console.WriteLine(host);// 使用Uri类来解析URL(这是更推荐的方法,因为它更健壮且能处理各种URL格式)  Uri uri = new Uri(host);// 直接从Uri对象中获取主机名  string hostname = uri.Host;int port = uri.Port;Console.WriteLine($"{hostname}:{port}"); // 输出: cpolard.26.tcp.cpolar.top  UseWebProxy("https://www.speedtest.net/", hostname, port);}}
}

GrassWebProxyClientV3:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;namespace GrassWebProxyV3
{public class IPport{public string IP { get; set; }public int Port { get; set; }}public class CpolarInfo{public int total { get; set; }public item[] items { get; set; }}public class item{public string name { get; set; }public string create_datetime { get; set; }public string pubulic_url { get; set; }}public class Ticket{public ulong TicketNo { get; set; }public string BeginDateTime { get; set; }public string EndDateTime { get; set; }}internal class Program{static string GetCploarInfo(){try{string jsonFilePath = "ipport.json"; // 替换为你的JSON文件路径  // 读取文件内容  string jsonContent = File.ReadAllText(jsonFilePath);// 反序列化JSON字符串到对象  IPport ipaddr = JsonConvert.DeserializeObject<IPport>(jsonContent);// 输出结果  Console.WriteLine($"{ipaddr.IP}:{ipaddr.Port}");// 创建一个TcpClient实例并连接到服务器  TcpClient client = new TcpClient($"{ipaddr.IP}", ipaddr.Port);// 获取一个NetworkStream对象以进行读写  NetworkStream stream = client.GetStream();// 将消息转换为字节数组  //string message = "Hello from the client!";//byte[] data = Encoding.ASCII.GetBytes(message);byte[] data = { 0x4E, 0x74, 0x01, 0xF2, 0x00, 0x00, 0x00, 0x01 };// 发送消息到服务器  stream.Write(data, 0, data.Length);// 读取服务器的响应  byte[] buffer = new byte[4096];int bytesRead = stream.Read(buffer, 0, buffer.Length);// 将接收到的字节转换为字符串  string responseData = Encoding.ASCII.GetString(buffer, 0, bytesRead);Console.WriteLine("Received from server: " + responseData);Console.WriteLine("ReceivedBytes:{0}", bytesRead);// 关闭连接  client.Close();//将Json写入文件File.WriteAllText("cpolarinfo.json", responseData);return responseData;}catch (Exception e){Console.WriteLine("Error: " + e.Message);}return string.Empty;}static void UseWebProxy(string webProxyUrl, string ip, int port){try{string jsonFilePath = "Ticket1.json";// 读取文件内容  string jsonContent = File.ReadAllText(jsonFilePath);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo}\r\n{ticket.BeginDateTime}---{ticket.EndDateTime}");//组装byte[] data = { 0x47, 0x50, 0x01, 0xF2, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01 };for (int i = 2, j = 7; i < data.Length; i++, j--){data[i] = (byte)(ticket.TicketNo >> (j * 8));//Console.WriteLine(data[i]);}// 将消息转换为字节数组  // 将 data 和 requestdata 合并到 buffer 中  byte[] requestdata = Encoding.UTF8.GetBytes(webProxyUrl);byte[] buf = new byte[data.Length + requestdata.Length];Buffer.BlockCopy(data, 0, buf, 0, data.Length);Buffer.BlockCopy(requestdata, 0, buf, data.Length, requestdata.Length);// 创建一个TcpClient实例并连接到服务器  TcpClient client = new TcpClient(ip, port);// 获取一个NetworkStream对象以进行读写  NetworkStream stream = client.GetStream();// 发送消息到服务器stream.Write(buf, 0, buf.Length);// 读取服务器的响应  byte[] buffer = new byte[81920];//int bytesRead = stream.Read(buffer, 0, buffer.Length);int totalBytesRead = 0;int bytesRead = 0;string responseData = string.Empty;while ((bytesRead = stream.Read(buffer, totalBytesRead, buffer.Length - totalBytesRead)) > 0){// 将接收到的字节转换为字符串  responseData = Encoding.UTF8.GetString(buffer, 0, bytesRead);Console.WriteLine("Received from server: " + responseData);Console.WriteLine("ReceivedBytes:{0}", bytesRead);totalBytesRead += bytesRead;// 可以在这里处理已经读取的数据(例如,写入文件或进行其他处理)  // 但请注意,如果处理逻辑复杂,最好先将数据复制到另一个缓冲区中  }// 现在 totalBytesRead 包含了从流中读取的总字节数Console.WriteLine("TotalReceivedBytes:{0}", totalBytesRead);// 关闭连接  client.Close();//将Json写入文件File.WriteAllText("response.html", responseData);}catch (Exception e){Console.WriteLine("Error: " + e.Message);}}static void Main(string[] args){Console.WriteLine("请求Cploar动态域名和端口信息......");string jsonContent = GetCploarInfo();CpolarInfo cpinfo = new CpolarInfo();if (jsonContent==string.Empty){jsonContent = File.ReadAllText("cpolarinfo.json");}else{//Console.WriteLine(jsonContent);cpinfo = JsonConvert.DeserializeObject<CpolarInfo>(jsonContent);Console.WriteLine($"{cpinfo.total}");for (int i = 0; i < cpinfo.total; i++){Console.WriteLine($"{cpinfo.items[i].name}\r\n{cpinfo.items[i].create_datetime}\r\n{cpinfo.items[i].pubulic_url}");}}string host = string.Empty;for (int i = 0; i < cpinfo.total; i++){if (cpinfo.items[i].name == "GrassWebProxy"){host = cpinfo.items[i].pubulic_url;}}Console.WriteLine(host);// 使用Uri类来解析URL(这是更推荐的方法,因为它更健壮且能处理各种URL格式)  Uri uri = new Uri(host);// 直接从Uri对象中获取主机名  string hostname = uri.Host;int port = uri.Port;Console.WriteLine($"{hostname}:{port}"); // 输出: cpolard.26.tcp.cpolar.top  UseWebProxy("https://www.speedtest.net/", hostname, port);//UseWebProxy("https://29bf2803.r15.cpolar.top/html/Welcome.html", hostname, port);}}
}

GrassWebProxyClientV4:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Policy;
using System.Net;
using System.Net.Sockets;namespace GrassWebProxyClientV4
{public class IPport{public string IP { get; set; }public int Port { get; set; }}public class CpolarInfo{public int total { get; set; }public item[] items { get; set; }}public class item{public string name { get; set; }public string create_datetime { get; set; }public string pubulic_url { get; set; }}public class Ticket{public ulong TicketNo { get; set; }public string BeginDateTime { get; set; }public string EndDateTime { get; set; }}public class GP{public static bool CheckFlag(ref byte[] msg){//"G" 71 0x47//"P" 80 0x50if (msg[0] == 0x47 && msg[1] == 0x50){Console.WriteLine("CheckFlag OK");return true;}return false;}static public Ticket ReadConfig(string cfg = "Ticket1.json"){// 读取文件内容  string jsonContent = File.ReadAllText(cfg);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo}\r\n{ticket.BeginDateTime}---{ticket.EndDateTime}");return ticket;}static public bool CheckTicket(ref byte[] msg, Ticket counterfoil){/*ulong ticket = (ulong)((msg[2] << 56) | (msg[3] << 48) | (msg[4] << 40)| (msg[5] << 32) | (msg[6] << 24) | (msg[7] << 16) | (msg[8] << 8) | msg[9]);*/ulong ticket = BitConverter.ToUInt64(msg, 2); // 从索引2开始读取8个字节//Console.WriteLine(ticket.ToString("X"));if (counterfoil.TicketNo == ticket){return true;}return false;}static public bool CheckFlagAdTicket(ref byte[] msg, Ticket counterfoil){//"G" 71 0x47//"P" 80 0x50ulong ticket = BitConverter.ToUInt64(msg, 2); // 从索引2开始读取8个字节if (msg[0] == 0x47 && msg[1] == 0x50 && counterfoil.TicketNo == ticket){return true;}return false;}}public class DynamicCploar{public static Uri GetGrassWebProxyHost(string notifyServer = "ipport.json"){try{string jsonFilePath = "ipport.json"; // 替换为你的JSON文件路径  // 读取文件内容  string jsonContent = File.ReadAllText(jsonFilePath);// 反序列化JSON字符串到对象  IPport ipaddr = JsonConvert.DeserializeObject<IPport>(jsonContent);// 输出结果  Console.WriteLine($"Notify Server: {ipaddr.IP}:{ipaddr.Port}");// 创建一个TcpClient实例并连接到服务器  TcpClient client = new TcpClient($"{ipaddr.IP}", ipaddr.Port);// 获取一个NetworkStream对象以进行读写  NetworkStream stream = client.GetStream();// 将消息转换为字节数组  //string message = "Hello from the client!";//byte[] data = Encoding.ASCII.GetBytes(message);byte[] data = { 0x4E, 0x74, 0x01, 0xF2, 0x00, 0x00, 0x00, 0x01 };// 发送消息到服务器  stream.Write(data, 0, data.Length);// 读取服务器的响应  byte[] buffer = new byte[1024];int bytesRead = stream.Read(buffer, 0, buffer.Length);// 将接收到的字节转换为字符串  string responseData = Encoding.ASCII.GetString(buffer, 0, bytesRead);//Console.WriteLine("Received from server: " + responseData);//Console.WriteLine("ReceivedBytes:{0}", bytesRead);// 关闭连接  client.Close();//将Json写入文件File.WriteAllText("cpolarinfo.json", responseData);CpolarInfo cpinfo = new CpolarInfo();if (responseData == string.Empty){responseData = File.ReadAllText("cpolarinfo.json");}else{//Console.WriteLine(responseData);cpinfo = JsonConvert.DeserializeObject<CpolarInfo>(responseData);//Console.WriteLine($"{cpinfo.total}");//for (int i = 0; i < cpinfo.total; i++)//{//    Console.WriteLine($"{cpinfo.items[i].name}\r\n{cpinfo.items[i].create_datetime}\r\n{cpinfo.items[i].pubulic_url}");//}}string host = string.Empty;for (int i = 0; i < cpinfo.total; i++){if (cpinfo.items[i].name == "GrassWebProxy"){host = cpinfo.items[i].pubulic_url;}}Console.WriteLine(host);// 使用Uri类来解析URL(这是更推荐的方法,因为它更健壮且能处理各种URL格式)  Uri uri = new Uri(host);return uri;}catch (Exception e){Console.WriteLine("Error: " + e.Message);}return null;}}internal class Program{public static async Task Main(string[] args){// 代理服务器信息  var host = DynamicCploar.GetGrassWebProxyHost("ipport.json");string proxyAddress = host.Host;int proxyPort = host.Port; // 代理服务器的端口  // 创建HttpClientHandler并设置代理  var handler = new HttpClientHandler{Proxy = new WebProxy(proxyAddress, proxyPort),UseProxy = true, // 默认情况下UseProxy是true,但明确设置可以避免混淆  // 如果代理服务器需要认证,可以添加以下两行(替换username和password)  // Proxy = new WebProxy(proxyAddress, proxyPort)  // {  //     Credentials = new NetworkCredential("username", "password")  // },  };using (HttpClient client = new HttpClient(handler)){string url = "https://www.iciba.com/";//加Headers["X-Proxy-Ticket"]var ticket = GP.ReadConfig("Ticket1.json");//"G" 71 0x47//"P" 80 0x50byte[] tickBytes = new byte[10];tickBytes[0] = 0x47;tickBytes[1] = 0x50;Buffer.BlockCopy(BitConverter.GetBytes(ticket.TicketNo), 0, tickBytes, 2, 8);string ticketHeader = Encoding.UTF8.GetString(tickBytes);// 设置请求头  client.DefaultRequestHeaders.Add("X-Proxy-Ticket", ticketHeader);HttpResponseMessage response = await client.GetAsync(url);response.EnsureSuccessStatusCode(); // 抛出异常如果状态码表示错误  string responseBody = await response.Content.ReadAsStringAsync();Console.WriteLine(responseBody);}}}
}

GrassWebProxyClientV5:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.IO.Compression;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;namespace GrassWebProxyClientV5
{public class IPport{public string IP { get; set; }public int Port { get; set; }}public class CpolarInfo{public int total { get; set; }public item[] items { get; set; }}public class item{public string name { get; set; }public string create_datetime { get; set; }public string pubulic_url { get; set; }}public class CustomDateTimeConverter : IsoDateTimeConverter{public CustomDateTimeConverter(){DateTimeFormat = "yyyyMMdd'T'HH:mm:ss";}}public class Ticket{public ulong TicketNo { get; set; }[JsonConverter(typeof(CustomDateTimeConverter))]public DateTime BeginDateTime { get; set; }[JsonConverter(typeof(CustomDateTimeConverter))]public DateTime EndDateTime { get; set; }}public class GP{public static bool CheckFlag(ref byte[] msg){//"G" 71 0x47//"P" 80 0x50if (msg[0] == 0x47 && msg[1] == 0x50){Console.WriteLine("CheckFlag OK");return true;}return false;}static public Ticket ReadConfig(string cfg = "Ticket1.json"){// 读取文件内容  string jsonContent = File.ReadAllText(cfg);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo}\r\n{ticket.BeginDateTime}---{ticket.EndDateTime}");return ticket;}static public bool CheckTicket(ref byte[] msg, Ticket counterfoil){/*ulong ticket = (ulong)((msg[2] << 56) | (msg[3] << 48) | (msg[4] << 40)| (msg[5] << 32) | (msg[6] << 24) | (msg[7] << 16) | (msg[8] << 8) | msg[9]);*/ulong ticket = BitConverter.ToUInt64(msg, 2); // 从索引2开始读取8个字节//Console.WriteLine(ticket.ToString("X"));if (counterfoil.TicketNo == ticket){return true;}return false;}static public bool CheckFlagAdTicket(ref byte[] msg, Ticket counterfoil){//"G" 71 0x47//"P" 80 0x50ulong ticket = BitConverter.ToUInt64(msg, 2); // 从索引2开始读取8个字节if (msg[0] == 0x47 && msg[1] == 0x50 && counterfoil.TicketNo == ticket){return true;}return false;}public static byte[] Compress(byte[] input){using (var memoryStream = new MemoryStream()){using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, true)){gzipStream.Write(input, 0, input.Length);}// 确保所有数据都被写入并压缩  return memoryStream.ToArray();}}public static byte[] DecompressGzip(byte[] gzip, int prebytes = 4096){using (var ms = new MemoryStream(gzip)){using (var gzipStream = new GZipStream(ms, CompressionMode.Decompress)){var buffer = new byte[prebytes];using (var memoryStreamOut = new MemoryStream()){int read;while ((read = gzipStream.Read(buffer, 0, buffer.Length)) > 0){memoryStreamOut.Write(buffer, 0, read);}return memoryStreamOut.ToArray();}}}}}public class DynamicCploar{public static Uri GetGrassWebProxyHost(string notifyServer = "ipport.json"){try{// 读取文件内容  string jsonContent = File.ReadAllText(notifyServer);// 反序列化JSON字符串到对象  IPport ipaddr = JsonConvert.DeserializeObject<IPport>(jsonContent);// 输出结果  Console.WriteLine($"Notify Server: {ipaddr.IP}:{ipaddr.Port}");// 创建一个TcpClient实例并连接到服务器  TcpClient client = new TcpClient($"{ipaddr.IP}", ipaddr.Port);// 获取一个NetworkStream对象以进行读写  NetworkStream stream = client.GetStream();// 将消息转换为字节数组  //string message = "Hello from the client!";//byte[] data = Encoding.ASCII.GetBytes(message);byte[] data = { 0x4E, 0x74, 0x01, 0xF2, 0x00, 0x00, 0x00, 0x01 };// 发送消息到服务器  stream.Write(data, 0, data.Length);// 读取服务器的响应  byte[] buffer = new byte[1024];int bytesRead = stream.Read(buffer, 0, buffer.Length);// 将接收到的字节转换为字符串  string responseData = Encoding.ASCII.GetString(buffer, 0, bytesRead);//Console.WriteLine("Received from server: " + responseData);//Console.WriteLine("ReceivedBytes:{0}", bytesRead);// 关闭连接  client.Close();//将Json写入文件File.WriteAllText("cpolarinfo.json", responseData);CpolarInfo cpinfo = new CpolarInfo();if (responseData == string.Empty){responseData = File.ReadAllText("cpolarinfo.json");}else{//Console.WriteLine(responseData);cpinfo = JsonConvert.DeserializeObject<CpolarInfo>(responseData);//Console.WriteLine($"{cpinfo.total}");//for (int i = 0; i < cpinfo.total; i++)//{//    Console.WriteLine($"{cpinfo.items[i].name}\r\n{cpinfo.items[i].create_datetime}\r\n{cpinfo.items[i].pubulic_url}");//}}string host = string.Empty;for (int i = 0; i < cpinfo.total; i++){if (cpinfo.items[i].name == "GrassWebProxy"){host = cpinfo.items[i].pubulic_url;}}Console.WriteLine(host);// 使用Uri类来解析URL(这是更推荐的方法,因为它更健壮且能处理各种URL格式)  Uri uri = new Uri(host);return uri;}catch (Exception e){Console.WriteLine("Error: " + e.Message);}return null;}}internal class Program{static void UseWebProxy(string webProxyUrl, string ip, int port){try{string jsonFilePath = "Ticket1.json";// 读取文件内容  string jsonContent = File.ReadAllText(jsonFilePath);// 反序列化JSON字符串到对象  Ticket ticket = JsonConvert.DeserializeObject<Ticket>(jsonContent);// 输出结果  Console.WriteLine($"{ticket.TicketNo},{ticket.BeginDateTime.ToString("yyyyMMdd'T'HH:mm:ss")}---{ticket.EndDateTime.ToString("yyyyMMdd'T'HH:mm:ss")}");//组装byte[] data = { 0x47, 0x50, 0x01, 0xF2, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01 };for (int i = 2, j = 7; i < data.Length; i++, j--){data[i] = (byte)(ticket.TicketNo >> (j * 8));//Console.WriteLine(data[i]);}// 将消息转换为字节数组  // 将 data 和 requestdata 合并到 buffer 中  byte[] requestdata = Encoding.UTF8.GetBytes(webProxyUrl);byte[] buf = new byte[data.Length + requestdata.Length];Buffer.BlockCopy(data, 0, buf, 0, data.Length);Buffer.BlockCopy(requestdata, 0, buf, data.Length, requestdata.Length);// 创建一个TcpClient实例并连接到服务器  TcpClient client = new TcpClient(ip, port);// 获取一个NetworkStream对象以进行读写  NetworkStream stream = client.GetStream();// 发送消息到服务器stream.Write(buf, 0, buf.Length);// 读取服务器的响应  byte[] buffer = new byte[81920];int totalBytesRead = 0;int bytesRead = 0;string responseData = string.Empty;while ((bytesRead = stream.Read(buffer, totalBytesRead, buffer.Length - totalBytesRead)) > 0){Console.WriteLine("ReceivedBytes:{0}", bytesRead);totalBytesRead += bytesRead;}// 关闭连接  client.Close();//解压var tmp = GP.DecompressGzip(buffer,totalBytesRead);// 将接收到的字节转换为字符串  responseData = Encoding.UTF8.GetString(tmp, 0, tmp.Length);// 现在 totalBytesRead 包含了从流中读取的总字节数Console.WriteLine("TotalReceivedBytes:{0}", totalBytesRead);Console.WriteLine("Received from server:\r\n" + responseData);//将Json写入文件File.WriteAllText("response.html", responseData);}catch (Exception e){Console.WriteLine("Error: " + e.Message);}}static void Main(string[] args){// 代理服务器信息  var host = DynamicCploar.GetGrassWebProxyHost("ipport.json");//string proxyAddress = host.Host;//int proxyPort = host.Port; // 代理服务器的端口  // 创建HttpClientHandler并设置代理  UseWebProxy("https://www.baidu.com/",host.Host,host.Port);string url="https://access-hsk.oray.com/loading?r=https%253A%252F%252Fu1506257x0%252Egoho%252Eco%253A443%252Fhtml%252Fopendata%252Ehtml&i=aHR0cHM6Ly91MTUwNjI1N3gwLmdvaG8uY286NDQzLDE0LjE1MS44MS43Mg%253D%253D&p=2979654771&k=aHV4eWNjXzE0LjE1MS44MS43Ml9FZGdlXzEyNyUyRTAlMkUwJTJFMF9XaW5kb3dzX1dpbmRvd3MlMjAxMA%3D%3D";UseWebProxy(url, host.Host, host.Port);url = "http://www.cjors.cn/";UseWebProxy(url, host.Host, host.Port);}}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/14150.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Kubernetes Pod间通信-第1篇】在单个子网中使用underlay网络实现Pod到Pod的通信

Kubernetes中Pod间的通信 本系列文章共3篇: 【Kubernetes Pod间通信-第1篇】在单个子网中使用underlay网络实现Pod到Pod的通信(本文介绍)【Kubernetes Pod间通信-第2篇】使用BGP实现Pod到Pod的通信【Kubernetes Pod间通信-第3篇】Kubernetes中Pod与ClusterIP服务之间的通信…

Excel 融合 deepseek

效果展示 代码实现 Function QhBaiDuYunAIReq(question, _Optional Authorization "Bearer ", _Optional Qhurl "https://qianfan.baidubce.com/v2/chat/completions")Dim XMLHTTP As ObjectDim url As Stringurl Qhurl 这里替换为你实际的URLDim postD…

MacOS 安装NVM

MacOS 安装NVM 方法一&#xff1a;使用Homebrew安装nvm 打开终端&#xff08;Terminal&#xff09;&#xff0c;输入以下命令安装Homebrew&#xff1a; /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"安装nvm…

采用idea中的HTTP Client插件测试

1.安装插件 采用idea中的HTTP Client插件进行接口测试,好处是不用打开post/swagger等多个软件,并且可以保存测试时的参数,方便后续继续使用. 高版本(2020版本以上)的idea一般都自带这个插件,如果没有也可以单独安装. 2.使用 插件安装完成(或者如果idea自带插件),会在每个Con…

LabVIEW铅酸蓄电池测试系统

本文介绍了基于LabVIEW的通用飞机铅酸蓄电池测试系统的设计与实现。系统通过模块化设计&#xff0c;利用多点传感器采集与高效的数据处理技术&#xff0c;显著提高了蓄电池测试的准确性和效率。 ​ 项目背景 随着通用航空的快速发展&#xff0c;对飞机铅酸蓄电池的测试需求也…

Python----Python高级(并发编程:协程Coroutines,事件循环,Task对象,协程间通信,协程同步,将协程分布到线程池/进程池中)

一、协程 1.1、协程 协程&#xff0c;Coroutines&#xff0c;也叫作纤程(Fiber) 协程&#xff0c;全称是“协同程序”&#xff0c;用来实现任务协作。是一种在线程中&#xff0c;比线程更加轻量级的存在&#xff0c;由程序员自己写程序来管理。 当出现IO阻塞时&#xff0c;…

go语言中的反射

为什么会引入反射 有时我们需要写一个函数&#xff0c;这个函数有能力统一处理各种值类型&#xff0c;而这些类型可能无法共享同一个接口&#xff0c;也可能布局未知&#xff0c;也有可能这个类型在我们设计函数时还不存在&#xff0c;这个时候我们就可以用到反射。 空接口可…

Mac电脑上好用的压缩软件

在Mac电脑上&#xff0c;有许多优秀的压缩软件可供选择&#xff0c;这些软件不仅支持多种压缩格式&#xff0c;还提供了便捷的操作体验和强大的功能。以下是几款被广泛推荐的压缩软件&#xff1a; BetterZip 功能特点&#xff1a;BetterZip 是一款功能强大的压缩和解压缩工具&a…

大学资产管理系统中的下载功能设计与实现

大学资产管理系统是高校信息化建设的重要组成部分&#xff0c;它负责记录和管理学校内所有固定资产的信息。随着信息技术的发展&#xff0c;下载功能成为提高资产管理效率的关键环节之一。 系统架构的设计是实现下载功能的基础。一个良好的系统架构能够确保数据的高效传输和存储…

UnityShader学习笔记——动态效果

——内容源自唐老狮的shader课程 目录 1.原理 2.Shader中内置的时间变量 3.Shader中经常会改变的数据 4.纹理动画 4.1.背景滚动 4.1.1.补充知识 4.1.2.基本原理 4.2.帧动画 4.2.1.基本原理 5.流动的2D河流 5.1.基本原理 5.2.关键步骤 5.3.补充知识 6.广告牌效果 …

Node.js 实现简单爬虫

介绍 爬虫是一种按照一定的规则&#xff0c;自动地抓取万维网信息的程序或者脚本。 本文将使用 Nodejs 编写一个简单的爬虫脚本&#xff0c;爬取一个美食网站&#xff0c;获取菜品的标题和图片链接&#xff0c;并以表格的形式输出。 准备工作 1、初始化项目 首先&#xff0…

JVM执行流程与架构(对应不同版本JDK)

直接上图&#xff08;对应JDK8以及以后的HotSpot&#xff09; 这里主要区分说明一下 方法区于 字符串常量池 的位置更迭&#xff1a; 方法区 JDK7 以及之前的版本将方法区存放在堆区域中的 永久代空间&#xff0c;堆的大小由虚拟机参数来控制。 JDK8 以及之后的版本将方法…

2025蓝桥杯JAVA编程题练习Day3

1.黛玉泡茶【算法赛】 问题描述 话说林黛玉闲来无事&#xff0c;打算在潇湘馆摆个茶局&#xff0c;邀上宝钗、探春她们一起品茗赏花。黛玉素来讲究&#xff0c;用的茶杯也各有不同&#xff0c;大的小的&#xff0c;高的矮的&#xff0c;煞是好看。这不&#xff0c;她从柜子里…

p5r预告信生成器API

p5r预告信生成器API 本人将js生成的p5r预告信使用go语言进行了重写和部署&#xff0c;并开放了其api&#xff0c;可以直接通过get方法获取预告信的png。 快速开始 http://api.viogami.tech/p5cc/:text eg: http://api.viogami.tech/p5cc/persona5 感谢p5r风格字体的制作者和…

VsCode创建VUE项目

1. 首先安装Node.js和npm 通过网盘分享的文件&#xff1a;vsCode和Node&#xff08;本人电脑Win11安装&#xff09; 链接: https://pan.baidu.com/s/151gBWTFZh9qIDS9XWMJVUA 提取码: 1234 它们是运行和构建Vue.js应用程序所必需的。 1.1 Node安装&#xff0c;点击下一步即可 …

软件设计模式

目录 一.创建型模式 抽象工厂 Abstract Factory 构建器 Builder 工厂方法 Factory Method 原型 Prototype 单例模式 Singleton 二.结构型模式 适配器模式 Adapter 桥接模式 Bridge 组合模式 Composite 装饰者模式 Decorator 外观模式 Facade 享元模式 Flyw…

Maven架构项目管理工具

1.1什么是Maven 翻译为“专家”&#xff0c;“内行”Maven是跨平台的项目管理工具。主要服务于基于Java平台的项目构建&#xff0c;依赖管理和项目信息管理。什么是理想的项目构建&#xff1f; 高度自动化&#xff0c;跨平台&#xff0c;可重用的组件&#xff0c;标准化的 什么…

【Linux】25.进程信号(1)

文章目录 1. 信号入门1.1 进程与信号的相关知识1.2 技术应用角度的信号1.3 注意1.4 信号概念1.5 信号处理常见方式概览 2. 产生信号2.1 通过终端按键产生信号2.2 调用系统函数向进程发信号2.3 由软件条件产生信号2.4 硬件异常产生信号2.5 信号保存 3. 阻塞信号3.1 信号其他相关…

第二个Qt开发实例:在Qt中利用GPIO子系统和sysfs伪文件系统实现按钮(Push Button)点击控制GPIO口(效果为LED2灯的灭和亮)

引言 本文承接博文 https://blog.csdn.net/wenhao_ir/article/details/145420998 里的代码&#xff0c;在那里面代码的基础上添加上利用sysfs伪文件系统实现按钮(Push Button)点击控制GPIO口的代码&#xff0c;进而实现LED2灯的灭和亮。 最终的效果是点击下面的LED按钮实现LED…

Unity 2D实战小游戏开发跳跳鸟 - 记录显示最高分

上一篇文章中我们实现了游戏的开始界面,在开始界面中有一个最高分数的UI,本文将接着实现记录最高分数以及在开始界面中显示最高分数的功能。 添加跳跳鸟死亡事件 要记录最高分,则需要在跳跳鸟死亡时去进行判断当前的分数是否是最高分,如果是最高分则进行记录,如果低于之前…