added files via upload

This commit is contained in:
Balackburn
2023-06-27 09:54:41 +02:00
commit 2ff6aac218
1420 changed files with 88898 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
## Usage
RemoteLog supports all the format specifiers of `NSLog` so it should be very easy to migrate to.
- Copy `RemoteLog.h` to `$THEOS/include`
- Change the ip addresses in the `RemoteLog.h` file to match your computer's ip address
- Include the header in any source files you want to use it in:
```
#include <RemoteLog.h>
```
- Replace calls to `NSLog` with calls to `RLog`:
```
RLog(@"Test log: %@", someObject);
```
- Run the python server on your computer and watch the logs coming in :)

View File

@@ -0,0 +1,61 @@
#ifndef _REMOTE_LOG_H_
#define _REMOTE_LOG_H_
#import <netinet/in.h>
#import <sys/socket.h>
#import <unistd.h>
#import <arpa/inet.h>
// change this to match your destination (server) IP address
#define RLOG_IP_ADDRESS "replace with ip"
#define RLOG_PORT 11909
__attribute__((unused)) static void RLogv(NSString* format, va_list args)
{
#if DEBUG
NSString* str = [[NSString alloc] initWithFormat:format arguments:args];
int sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sd <= 0)
{
NSLog(@"[RemoteLog] Error: Could not open socket");
return;
}
int broadcastEnable = 1;
int ret = setsockopt(sd, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
if (ret)
{
NSLog(@"[RemoteLog] Error: Could not open set socket to broadcast mode");
close(sd);
return;
}
struct sockaddr_in broadcastAddr;
memset(&broadcastAddr, 0, sizeof broadcastAddr);
broadcastAddr.sin_family = AF_INET;
inet_pton(AF_INET, RLOG_IP_ADDRESS, &broadcastAddr.sin_addr);
broadcastAddr.sin_port = htons(RLOG_PORT);
char* request = (char*)[str UTF8String];
ret = sendto(sd, request, strlen(request), 0, (struct sockaddr*)&broadcastAddr, sizeof broadcastAddr);
if (ret < 0)
{
NSLog(@"[RemoteLog] Error: Could not send broadcast");
close(sd);
return;
}
close(sd);
#endif
}
__attribute__((unused)) static void RLog(NSString* format, ...)
{
#if DEBUG
va_list args;
va_start(args, format);
RLogv(format, args);
va_end(args);
#endif
}
#endif

View File

@@ -0,0 +1,19 @@
# created by Tonyk7
import logging
import socket
# change this to match the port in RemoteLog.h
rlog_port = 11909
# code is from: https://gist.github.com/majek/1763628
def udp_server(host="0.0.0.0", port=rlog_port):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
while True:
(data, addr) = s.recvfrom(128*1024)
yield data
for data in udp_server():
print(data.decode('utf-8').strip())