diff --git a/locale/tr/LC_MESSAGES/pooler.po b/locale/tr/LC_MESSAGES/pooler.po index fb22f18..2825b10 100644 --- a/locale/tr/LC_MESSAGES/pooler.po +++ b/locale/tr/LC_MESSAGES/pooler.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-14 15:59+0300\n" +"POT-Creation-Date: 2024-07-18 19:32+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -41,88 +41,108 @@ msgstr "Ana makine adı havuz konfigürasyonunda belirtilmedi, geçiliyor: %s" msgid "Loaded the configuration" msgstr "" -#: src/main.c:42 +#: src/main.c:58 #, c-format msgid "%s: successfuly loaded the pool info" msgstr "%s: havuz bilgisi başarıyla yüklendi" -#: src/main.c:46 +#: src/main.c:62 #, c-format msgid "%s: failed to load the pool info (%s)" msgstr "%s: havuz bilgisini yüklemek başarısız oldu (%s)" -#: src/main.c:50 +#: src/main.c:66 #, c-format msgid "%s: successfuly loaded the package list" msgstr "%s: paket listesi başarıyla yüklendi" -#: src/main.c:54 +#: src/main.c:70 #, c-format msgid "%s: failed to load the package list (%s)" msgstr "%s: paket listesini yüklemek başarısız oldu (%s)" -#: src/main.c:67 +#: src/main.c:88 +#, c-format +msgid "Request from %s: PING (%s)" +msgstr "" + +#: src/main.c:92 +#, c-format +msgid "Request from %s: INFO (%s)" +msgstr "" + +#: src/main.c:96 +#, c-format +msgid "Request from %s: LIST (%s)" +msgstr "" + +#: src/main.c:100 +#, c-format +msgid "Request from %s: PULL (%s)" +msgstr "" + +#: src/main.c:109 msgid "Configuration file not specified" msgstr "Konfigürasyon dosyası belirtilmedi" -#: src/main.c:86 +#: src/main.c:128 #, c-format msgid "Failed to open the log file: %s" msgstr "Kayıt dosyasını açmak başarısız oldu: %s" -#: src/main.c:98 +#: src/main.c:140 msgid "Please specify a valid thread count (1-1000)" msgstr "Lütfen geçerli bir işlem sayısı belirtin (1-1000)" -#: src/main.c:103 +#: src/main.c:145 msgid "Pool directory not specified" msgstr "Havuz dizini belirtilmemiş" -#: src/main.c:108 +#: src/main.c:150 #, c-format msgid "Cannot access to the pool directory: %s" msgstr "Havuz dizinine erişilemiyor: %s" -#: src/main.c:113 +#: src/main.c:155 msgid "Please specify at least one pool in the configuration" msgstr "Lütfen konfigürasyonda en az bir havuz belirtin" -#: src/main.c:118 +#: src/main.c:160 #, c-format msgid "Failed to use pool directory: %s" msgstr "Havuz dizini kullanmak başarısız oldu: %s" -#: src/main.c:124 +#: src/main.c:166 #, c-format msgid "Hostname not specified for pool, skipping: %s" msgstr "Ana makine adı havuz konfigürasyonunda belirtilmedi, geçiliyor: %s" -#: src/main.c:132 +#: src/main.c:174 #, c-format msgid "Failed to add pool to the list: %s" msgstr "Havuzu listeye eklemek başarısız oldu: %s" -#: src/main.c:140 +#: src/main.c:182 #, c-format msgid "Failed to sync the pools: %s" msgstr "Havuzları sekronize etmek başarısız oldu: %s" -#: src/main.c:145 +#: src/main.c:187 #, fuzzy msgid "None of the pools is available for serving" msgstr "Havuzların hiçbiri sunmak için müsait değil" -#: src/main.c:149 +#: src/main.c:191 #, c-format msgid "Serving %lu pool on %s" msgstr "%lu tane havuz %s adresinde sunuluyor" -#: src/main.c:149 +#: src/main.c:191 #, c-format msgid "Serving %lu pools on %s" msgstr "%lu tane havuz %s adresinde sunuluyor" -#: src/main.c:152 +#: src/main.c:194 #, c-format msgid "Failed to start the server: %s" msgstr "Sunucuyu başlatmak başarısız oldu: %s" diff --git a/src/main.c b/src/main.c index aee1ea9..3162ed6 100644 --- a/src/main.c +++ b/src/main.c @@ -22,10 +22,9 @@ // clang-format on +#include #include #include -#include -#include #include #include #include @@ -35,6 +34,23 @@ #include "intl.h" #include "log.h" +void sockaddr_to_str(struct sockaddr *addr, char *str) { + struct sockaddr_in *ipv4; + struct sockaddr_in6 *ipv6; + + switch (addr->sa_family) { + case AF_INET: + ipv4 = (struct sockaddr_in *)addr; + inet_ntop(AF_INET, &ipv4->sin_addr, str, INET_ADDRSTRLEN); + break; + + case AF_INET6: + ipv6 = (struct sockaddr_in6 *)addr; + inet_ntop(AF_INET6, &ipv6->sin6_addr, str, INET6_ADDRSTRLEN); + break; + } +} + bool sync_callback( lm_ctx_t *ctx, lm_pool_t *pool, lm_ctx_sync_state_t state, size_t current, size_t total, void *data) { switch (state) { @@ -62,6 +78,32 @@ bool sync_callback( return true; } +bool serve_callback(lm_pool_t *pool, lm_mptp_t *packet, struct sockaddr *addr, void *data) { + char ipaddr[INET6_ADDRSTRLEN]; + bzero(ipaddr, sizeof(ipaddr)); + sockaddr_to_str(addr, ipaddr); + + switch (MPTP_FLAGS_CODE(packet)) { + case MPTP_C2S_PING: + info(_("Request from %s: PING (%s)"), ipaddr, pool->name); + break; + + case MPTP_C2S_INFO: + info(_("Request from %s: INFO (%s)"), ipaddr, pool->name); + break; + + case MPTP_C2S_LIST: + info(_("Request from %s: LIST (%s)"), ipaddr, pool->name); + break; + + case MPTP_C2S_PULL: + info(_("Request from %s: PULL (%s)"), ipaddr, pool->name); + break; + } + + return true; +} + int main(int argc, char *argv[]) { if (argc != 2) { error(_("Configuration file not specified")); @@ -148,7 +190,7 @@ int main(int argc, char *argv[]) { info(pool_count == 1 ? _("Serving %lu pool on %s") : _("Serving %lu pools on %s"), pool_count, addr); - if (!lm_ctx_serve(&ctx, addr, config_get_integer("threads"))) { + if (!lm_ctx_serve(&ctx, addr, config_get_integer("threads"), serve_callback, NULL)) { error(_("Failed to start the server: %s"), lm_strerror()); goto end; }