depicus

  just another nerd on the interweb…



  • home
  • gallery
  • play page
  • support
  • videos
  • what is depicus

Allowing a VMWare server to send SMTP mail

Author: The Man



Quite easy if you have enabled ssh access

1. Create a file in the /etc/vmware/firewall/ directory called smtp.xml with the following content. I usually create on the mac and just sftp it up.

View Code XML
1
2
3
4
5
6
7
8
9
10
11
12
13
<ConfigRoot>
  <service id='1000'>
    <id>SMTP_Outbound</id>
    <rule>
      <direction>outbound</direction>
      <protocol>tcp</protocol>
      <porttype>dst</porttype>
      <port>25</port>
    </rule>
    <enabled>true</enabled>
    <required>false</required>
  </service>
</ConfigRoot>

2. From the command line just esxcli network firewall refresh

All done, and it should look like this.

Tweet

May 15th, 2012  |  Posted in Interweb  |  No Comments »

Using a Raspberry Pi as a Wake on Lan Forwarder

Author: The Man



Well I don’t have a Raspberry Pi yet but for $35 it’s a bargain and could be used as a WoL forwarder for those of you who don’t have a router that allow packet forwarding for Subnet Directed Broadcasts. This is a first draft of an app you can run.

1. Fire up your Raspberry Pi and download the developer tools, I am assuming your using a Debian based version of Linux. Simply type apt-get install build-essential

2. Copy the code below and place into a file e.g. nano wolf.c then save

3. Compile with gcc -o wolf wolf.c then run with ./wolf

* don’t forget to change to the name of your network interface #define ETHNAME “en1″ usually eth0 on Linux but en0 on a mac.

That’s basically all there is to it. I am going to look at running as a service and report back later.

View Code C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 
//
//  wolf.c
//
//  Created by Brian on 12/05/2012.
//  Copyright (c) 2012 Depicus. All rights reserved.
//
 
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/types.h>
 
#define ETHNAME "en1"
#define BUFLEN 102
 
char myipaddress[16];
char str[1024];
enum { ADDRS_SIZE = 8 };
struct in_addr bcast;
struct in_addr nmask;
static char netcard[16];
 
char const *getadapteraddress(char adapter[5])
{
    int fd;
    struct ifreq ifr;
    u_char *addr;
    u_char *braddr;
    u_char *naddr;
    fd = socket (AF_INET, SOCK_DGRAM,0);
    if ((fd = socket(AF_INET,SOCK_DGRAM,0)) < 0) 
    { 
        fprintf(stderr,"Error: Unable to create socket\n"); 
        perror("socket"); 
        return "-1"; 
    } 
    memset (&ifr, 0, sizeof (struct ifreq));
    strcpy (ifr.ifr_name, adapter);
    ifr.ifr_addr.sa_family = AF_INET;
    ioctl(fd, SIOCGIFADDR, &ifr);
    addr=(u_char*)&(((struct sockaddr_in * )&ifr.ifr_addr)->sin_addr);
    //printf("eth %s, addr %d.%d.%d.%d\n", ifr.ifr_name,addr[0],addr[1],addr[2],addr[3]);
    strcat(netcard,ifr.ifr_name);
    sprintf (myipaddress,"%d.%d.%d.%d",addr[0],addr[1],addr[2],addr[3]);
 
    memset (&ifr, 0, sizeof (struct ifreq));
    strcpy (ifr.ifr_name, adapter);
    ifr.ifr_addr.sa_family = AF_INET;
    ioctl(fd, SIOCGIFBRDADDR, &ifr);
    braddr=(u_char*)&(((struct sockaddr_in * )&ifr.ifr_broadaddr)->sin_addr);
    //printf("eth broadcast %d.%d.%d.%d\n",braddr[0],braddr[1],braddr[2],braddr[3]);
    memcpy(&bcast, &(*(struct sockaddr_in *)&ifr.ifr_broadaddr).sin_addr, 4);
 
 
    memset (&ifr, 0, sizeof (struct ifreq));
    strcpy (ifr.ifr_name, adapter);
    ifr.ifr_addr.sa_family = AF_INET;
    ioctl(fd, SIOCGIFNETMASK, &ifr);
    naddr=(u_char*)&(((struct sockaddr_in * )&ifr.ifr_broadaddr)->sin_addr);
    //printf("eth subnet %d.%d.%d.%d\n",braddr[0],braddr[1],braddr[2],braddr[3]);
    memcpy(&nmask, &(*(struct sockaddr_in *)&ifr.ifr_broadaddr).sin_addr, 4);
 
    close(fd);
    return myipaddress;
}
 
// Main section
 
void sendWoLPacket(char mesg[101])
{
    int sendSocket;
    struct sockaddr_in wt;
    memset(&wt, 0, sizeof(wt));
    wt.sin_family = AF_INET;
    wt.sin_port = htons(9);
    wt.sin_addr.s_addr = inet_addr(inet_ntoa(bcast)); //"192.168.43.255");
 
    sendSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    int udpflag = 1;
    int retval;
    retval = setsockopt(sendSocket, SOL_SOCKET, SO_BROADCAST, &udpflag, sizeof(udpflag));
    if (retval < 0)
    {
        sprintf (str,"failed to setsockopt: %s",strerror(errno));
        printf("%s\n",str);
    }
 
    int res;
    res = sendto(sendSocket,mesg,BUFLEN,0,(struct sockaddr *)&wt,sizeof(wt));
 
    if (res < 0)
    {
        sprintf (str,"failed to send: %s",strerror(errno));
        printf("%s\n", str);
    }
    else 
    {
        printf("Resent WoL on port %i\n",9);
    }
 
 
}
 
int main(int argc, const char * argv[])
{
    printf("Starting WoLf:\n");
 
    char const *cptr;
    cptr = getadapteraddress(ETHNAME);
    printf("%s: inet %s netmask %s broadcast %s \n",netcard,cptr,inet_ntoa(nmask),inet_ntoa(bcast));
 
    int sendSocket,n;
    struct sockaddr_in servaddr,cliaddr;
    socklen_t len;
    char mesg[101]; //wol packet size is 102 so 0 to 101
    //int bytes;
 
    sendSocket=socket(AF_INET,SOCK_DGRAM,0);
 
    bzero(&servaddr,sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
    servaddr.sin_port=htons(4343);
    bind(sendSocket,(struct sockaddr *)&servaddr,sizeof(servaddr));
 
    for (;;)
    {
        len = sizeof(cliaddr);
        n = recvfrom(sendSocket,mesg,1000,0,(struct sockaddr *)&cliaddr,&len);
        sendto(sendSocket,mesg,n,0,(struct sockaddr *)&cliaddr,sizeof(cliaddr));
        printf("-------------------------------------------------------\n");
        mesg[n] = 0;
        printf("\nPacket Received with length %i\n", n);
        //mesg[n] = 0;
 
        if (!n == 102) continue;
 
        printf("mac address: %02X:%02X:%02X:%02X:%02X:%02X \n",(unsigned char)mesg[6],(unsigned char)mesg[7],(unsigned char)mesg[8],(unsigned char)mesg[9],(unsigned char)mesg[10],(unsigned char)mesg[11]);
 
        char ffAddress[18] = "";
        char mAddress[18] = "";
 
        // check that the first six digits are FF
        sprintf (ffAddress,"%02X:%02X:%02X:%02X:%02X:%02X",(unsigned char)mesg[0],(unsigned char)mesg[1],(unsigned char)mesg[2],(unsigned char)mesg[3],(unsigned char)mesg[4],(unsigned char)mesg[5]);
        if (!strncmp(ffAddress,"FF:FF:FF:FF:FF:FF",17)  == 0)
        {
            continue;
        }
 
        // check we have six repeating mac addresses
        int y;
        for (y = 0; y < 6; y++) 
            {
                int mply = 6 * (y + 1);
                sprintf (mAddress,"%02X:%02X:%02X:%02X:%02X:%02X",(unsigned char)mesg[mply],(unsigned char)mesg[mply+1],(unsigned char)mesg[mply+2],(unsigned char)mesg[mply+3],(unsigned char)mesg[mply+4],(unsigned char)mesg[mply+5]);
                printf("%i %s \n",y, mAddress);
 
                if (y > 0)
                {
                    if (!strncmp(mAddress,ffAddress,strlen(ffAddress)) == 0)
                    {
                        continue;
                    }
 
                }
                stpcpy(ffAddress,mAddress);
            }
 
        //int y;
        //for (y = 0; y < sizeof(mesg); y++) 
        //{
        //    printf("%i = %02X ",y,(unsigned char)mesg[y]);
        //}
        printf("End Packet\n");
        sendWoLPacket(mesg);
 
    }
 
    printf("Fin\n");
    return 0;
}
Tweet

Tags: Raspberry Pi
May 14th, 2012  |  Posted in Computers, Interweb, Software Development, Wake On Lan  |  No Comments »

Get rid of the dock icon for Skydrive on OS X

Author: The Man



Why this wasn’t the default is beyond me but….

defaults write /Applications/SkyDrive.app/Contents/Info.plist LSUIElement 1

Also it’s a long way off Dropbox functionality, thank god for the 25Gb

Tweet

Tags: Cloud, Dock Icon, Dropbox, Skydrive
April 24th, 2012  |  Posted in Computers, Interweb, OS X  |  2 Comments »

No Windows Phone app any time soon…

Author: The Man



Well a few days later and it looks like there won’t be a Windows Phone version anytime soon. Here is why.

1. There is no solid reliable way to get your own IP address and while there are bodges I prefer not to release stuff that requires such hacks to get them to work as they, at some point will fail to work.

2. There seems to be no reliable way to use UDP broadcasts – WHAT !?!?!? yes but there you go.

Not great news but maybe Windows Phone 8 will finally catch up to where Android and iOS were two years ago.

Tweet

Tags: Android, Frustration, iOS, Mobile, Windows 7 Phone, Windows Phone 8
April 17th, 2012  |  Posted in Software Development, Wake On Lan, Windows Phone  |  No Comments »

Windows Phone – on the way :)

Author: The Man



Tweet

Tags: Beta
April 15th, 2012  |  Posted in Wake On Lan, Windows Phone  |  No Comments »

<< Previous

  • how i pay the bills

  • google rank getter

    Android Apache Aperture Apple App Store bbPress Bike Bug Canon 7D Code Dell DotNet Dropbox Fail Firefox forum Frustration Golf iPad iPhone iPod Touch Java Kenya Linksys Macbook Pro Netgear Objective C Open Source OSX PHP Rejected Safari Server Skype Support Ubuntu Update WakeOnLan Wake On Lan Wifi Windows Windows 7 Phone Wireshark Wordpress XCode
  • depicus in africa

    depicus in africa
  • friends

    • Agency Manager
    • AllClear Travel
    • Climbing Tikes
    • Globe Bloggers
    • Marchday
    • The Travel Toad
  • gallery

    Bisley Developments Ltd IMG_3118 IMG_3437 IMG_2962
  • videos

    Vimeo

    YouTube
  • twitter

    • Holy geekness batman we have an Arduino doing Wake on Lan forwarding programmed in less than 4 hours… amazing - #iamanubergeektoday view
    • Arduino WoLF app coming along nicely view
    • RT @pasm69: On the one hand we are in a #drought says #thameswater, on the other £4.1B to throw rainwater down the #supersewer #itisjust ... view
  • recent comments

    • Sef: Yo, thats 720p @ 60fps. Huge Difference… in file size, processing, everything. DSLRs aren’t there...
    • Finson: Worked..!! Replaced all the InstallOnLHS and InstallOnWinXP with value 0 and the installation completed...
    • Geux: Terminal command didn’t work, but editing the plist manually did the trick. Thanks !!!
    • Nebras Alattar: Hi The code that you posted is very useful, but i faced a problem when i run the app i got the...
    • leon: how can I get the ImageIO.framework ? I’ve read that it doesn’t exist for iphone!!!! Can anyone...
  • archives

    • May 2012 (2)
    • April 2012 (4)
    • February 2012 (8)
    • January 2012 (6)
    • December 2011 (7)
    • November 2011 (1)
    • October 2011 (2)
    • September 2011 (2)
    • August 2011 (4)
    • July 2011 (6)
    • June 2011 (9)
    • May 2011 (8)
    • April 2011 (2)
    • February 2011 (6)
    • January 2011 (14)
    • December 2010 (9)
    • November 2010 (8)
    • October 2010 (14)
    • September 2010 (6)
    • August 2010 (9)
    • July 2010 (1)
    • June 2010 (2)
    • May 2010 (2)
    • April 2010 (2)
    • March 2010 (11)
    • February 2010 (3)

Copyright © - depicus | Entries (RSS) | Comments (RSS)

WordPress theme butchered and amended by me.