const std = @import("std"); const httpz = @import("httpz"); const protocol =…
- User
const std = @import("std"); const httpz = @import("httpz"); const protocol = @import("protocol"); const Base64Encoder = @import("std").base64.standard.Encoder;
pub fn onQueryDispatch(_: *httpz.Request, res: *httpz.Response) !void { std.log.debug("onQueryDispatch", .{});
var proto = protocol.DispatchRegionData.init(res.arena); proto.retcode = 0; try proto.region_list.append(.{ .name = .{ .Const = "YunliSR" }, .display_name = .{ .Const = "YunliSR" }, .env_type = .{ .Const = "0" }, .title = .{ .Const = "YunliSR" }, .dispatch_url = .{ .Const = "http://192.168.1.3:21000/query_gateway" }, }); const data = try proto.encode(res.arena); const size = Base64Encoder.calcSize(data.len); const output = try res.arena.alloc(u8, size); _ = Base64Encoder.encode(output, data); res.body = output;}
pub fn onQueryGateway(_: *httpz.Request, res: *httpz.Response) !void { std.log.debug("onQueryGateway", .{});
var proto = protocol.Gateserver.init(res.arena); proto.retcode = 0; proto.port = 23301; proto.ip = .{ .Const = "192.168.1.3" }; proto.AIPNJNLHFBP = .{ .Const = "0" }; // ifix_version proto.LLFDDPLHGBM = .{ .Const = "8023974" }; // lua_version proto.lua_url = .{ .Const = "https://autopatchcn.bhsr.com/lua/BetaLive/output_8023974_8a20ac590d04" }; proto.asset_bundle_url = .{ .Const = "https://autopatchcn.bhsr.com/asb/BetaLive/output_8023914_1c5d3bc509a7" }; proto.ex_resource_url = .{ .Const = "https://autopatchcn.bhsr.com/design_data/BetaLive/output_8023914_b27d1db5c7a4" }; proto.IALOEKGOJOC = true; proto.CCHNJJFKGPM = true; proto.DNNFDDBEFOI = true; proto.HBCEBKFAGIA = true; proto.BOKGICKLEGO = true; proto.FIOHEKDJNCG = true; proto.MCEIPIBAMDB = true; proto.CNAKLGMDLPE = true; //proto.Unknown = true; //proto.Unknown = true; proto.NNGLEBKCMLA = true; proto.APJECJMGAKC = true; proto.NPHDIMJOKNI = true; proto.JGCIILJEHHE = true; proto.LAABLMNKLLD = true; proto.OFJAKNEDMDM = true; proto.EBKBNEKCOHI = true; const data = try proto.encode(res.arena); const size = Base64Encoder.calcSize(data.len); const output = try res.arena.alloc(u8, size); _ = Base64Encoder.encode(output, data); res.body = output;}
i want to make and change 192.168.1.3 to something i can access even on different wifi
- Assistant
To make your server accessible from different networks (even when you are on different Wi-Fi connections), you need to replace the local IP address
192.168.1.3(which is only accessible within your local network) with a public IP address or a domain name that resolves to your public IP. Here's how you can do it:-
Get Your Public IP Address:
- Find out your public IP address by visiting a website like whatismyip.com. This is the IP address that devices outside your local network will use to reach your server.
-
Set Up Port Forwarding (If Necessary):
- If your server is behind a router and uses NAT (Network Address Translation), you'll need to set up port forwarding on your router to forward incoming connections on the required ports (e.g.,
21000,23301) to your server's local IP address. - Refer to your router's manual for instructions on how to set up port forwarding.
- If your server is behind a router and uses NAT (Network Address Translation), you'll need to set up port forwarding on your router to forward incoming connections on the required ports (e.g.,
-
Use a Domain Name (Optional but Recommended):
- Instead of using the public IP address directly, you can use a domain name. This makes it easier to remember and allows you to handle IP address changes more gracefully.
- You can register a domain and point it to your public IP address using DNS A records.
- For dynamic IPs, consider using a Dynamic DNS service like
No-IPorDynDNSto automatically update your domain with your current IP.
-
Update Your Code:
- Replace
192.168.1.3with your public IP address or domain name in your code.
- Replace
Here's how you can modify your code:
// Replace with your public IP or domain name const PUBLIC_IP_OR_DOMAIN = "your_public_ip_or_domain"; // In onQueryDispatch proto.dispatch_url = .{ .Const = "http://" ++ PUBLIC_IP_OR_DOMAIN ++ ":21000/query_gateway" }; // In onQueryGateway proto.ip = .{ .Const = PUBLIC_IP_OR_DOMAIN };Make sure to:
- Replace
"your_public_ip_or_domain"with your actual public IP address or domain name. - Ensure that your firewall allows incoming connections on the required ports.
- Test the connection from an external network to confirm that it's accessible.
Note: Exposing your server to the internet comes with security risks. Make sure to secure your server properly:
- Use strong passwords and authentication mechanisms.
- Keep your server and software up to date with security patches.
- Consider using encryption (HTTPS) to protect data in transit.
By making these changes, your server should be accessible from different networks, allowing you (and others) to connect even when on different Wi-Fi connections.
-