mirror of
https://github.com/ps5-payload-dev/ftpsrv.git
synced 2026-10-19 02:10:54 -05:00
notify user on the server is running
This commit is contained in:
1 parent
a7cebaec57
commit
965beeeca4
4 files changed
+69
-1
No files matched your search
@@ -29,7 +29,7 @@ CFLAGS := -Wall -Werror
|
||||
|
||||
all: $(ELF)
|
||||
|
||||
$(ELF): main.c cmd.c
|
||||
$(ELF): main.c cmd.c notify.c
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
clean:
|
||||
|
||||
@@ -36,6 +36,7 @@ along with this program; see the file COPYING. If not, see
|
||||
|
||||
#include "cmd.h"
|
||||
#include "log.h"
|
||||
#include "notify.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -263,6 +264,7 @@ static int
|
||||
ftp_serve(uint16_t port) {
|
||||
struct sockaddr_in server_addr;
|
||||
struct sockaddr_in client_addr;
|
||||
static int notify_user = 0;
|
||||
char ip[INET_ADDRSTRLEN];
|
||||
struct ifaddrs *ifaddr;
|
||||
int ifaddr_wait = 1;
|
||||
@@ -301,6 +303,10 @@ ftp_serve(uint16_t port) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!notify_user) {
|
||||
notify("Serving FTP on %s:%d (%s)\n", ip, port, ifa->ifa_name);
|
||||
notify_user = 1;
|
||||
}
|
||||
FTP_LOG_PRINTF("Serving FTP on %s:%d (%s)\n", ip, port, ifa->ifa_name);
|
||||
ifaddr_wait = 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2024 John Törnblom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 3, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
typedef struct notify_request {
|
||||
char useless1[45];
|
||||
char message[3075];
|
||||
} notify_request_t;
|
||||
|
||||
|
||||
int sceKernelSendNotificationRequest(int, notify_request_t*, size_t, int);
|
||||
|
||||
|
||||
void
|
||||
notify(const char *fmt, ...) {
|
||||
notify_request_t req;
|
||||
va_list args;
|
||||
|
||||
bzero(&req, sizeof req);
|
||||
va_start(args, fmt);
|
||||
vsnprintf(req.message, sizeof req.message, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
sceKernelSendNotificationRequest(0, &req, sizeof req, 0);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/* Copyright (C) 2024 John Törnblom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 3, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
void notify(const char *fmt, ...);
|
||||
Reference in new issue
Block a user