mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
add possibility to change UDP ip+port via env variables
This commit is contained in:
parent
15254ffce5
commit
67c0ecfb23
@ -8,7 +8,7 @@
|
||||
#include "py/objstr.h"
|
||||
|
||||
#include "trezor-crypto/ecdsa.h"
|
||||
#include "trezor.crypto.curve.nist256p1.h"
|
||||
#include "trezor-crypto/nist256p1.h"
|
||||
|
||||
typedef struct _mp_obj_Nist256p1_t {
|
||||
mp_obj_base_t base;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "py/objstr.h"
|
||||
|
||||
#include "trezor-crypto/ecdsa.h"
|
||||
#include "trezor.crypto.curve.secp256k1.h"
|
||||
#include "trezor-crypto/secp256k1.h"
|
||||
|
||||
typedef struct _mp_obj_Secp256k1_t {
|
||||
mp_obj_base_t base;
|
||||
|
@ -2,8 +2,9 @@
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TREZOR_PORT 21324
|
||||
#define TREZOR_UDP_PORT 21324
|
||||
|
||||
static int s;
|
||||
static struct sockaddr_in si_me, si_other;
|
||||
@ -17,8 +18,18 @@ void msg_init(void)
|
||||
fcntl(s, F_SETFL, O_NONBLOCK);
|
||||
|
||||
si_me.sin_family = AF_INET;
|
||||
si_me.sin_port = htons(TREZOR_PORT);
|
||||
si_me.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
const char *ip = getenv("TREZOR_UDP_IP");
|
||||
if (ip) {
|
||||
si_me.sin_addr.s_addr = inet_addr(ip);
|
||||
} else {
|
||||
si_me.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
}
|
||||
const char *port = getenv("TREZOR_UDP_PORT");
|
||||
if (port) {
|
||||
si_me.sin_port = htons(atoi(port));
|
||||
} else {
|
||||
si_me.sin_port = htons(TREZOR_UDP_PORT);
|
||||
}
|
||||
|
||||
int b;
|
||||
b = bind(s, (struct sockaddr*)&si_me, sizeof(si_me));
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define CMD(X) (*((__IO uint8_t *)((uint32_t)(0x60000000))) = (X))
|
||||
#define DATA(X) (*((__IO uint8_t *)((uint32_t)(0x60000000 | 0x10000))) = (X))
|
||||
|
||||
static void DATAS(void *bytes, int len);
|
||||
static void DATAS(const void *bytes, int len);
|
||||
|
||||
void sram_init(void) {
|
||||
__GPIOE_CLK_ENABLE();
|
||||
|
@ -1,8 +1,9 @@
|
||||
#!/usr/bin/python
|
||||
import socket
|
||||
import os
|
||||
|
||||
UDP_IP = '127.0.0.1'
|
||||
UDP_PORT = 21324
|
||||
UDP_IP = os.getenv('TREZOR_UDP_IP', '127.0.0.1')
|
||||
UDP_PORT = int(os.getenv('TREZOR_UDP_PORT', '21324'))
|
||||
MESSAGE = b'Hello, World!'
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
Loading…
Reference in New Issue
Block a user