That's a difficult one...
Assuming that GoT uses something similar to the British rules of ascension(See Note), then Jon would have the rightful claim...
Succession to the British throne is determined by descent, gender, legitimacy, and religion. Under common law, the crown is inherited by an individual's children and by a childless individual's nearest collateral line.
...except that he would still not be a legitimate heir, as he would be the bastard son of Rhaegar & Lyanna, rather than Elia.
On the other hand, Daenerys would nominally be eligible even if Jon was legitimate but only if GoT were using rules changed after the release of A Dance with Dragons.
British succession now [since 2015] casts all children in descending order by date of birth [absolute primogeniture], no longer just the male line [male-preference primogeniture] . The law is not retrograde, which means that, for instance, Anne is not suddenly promoted to 2nd in line after Charles.
However - it is unlikely that GoT, the series or the books, will be using that system in its modern state. It is far likely to be using the earlier medieval system from which it derived...
The current succession law in the United Kingdom evolved from succession law in both England and Scotland. Originally in both countries, there were no fixed rules governing succession to the throne. The individual could have relied on inheritance, statute, election (by Parliament or by another body), nomination (by a reigning sovereign in his or her will), conquest or prescription (de facto possession of the Crown). It was often unclear which of these bases should take precedence; often, the outcome depended not on the legal strength of the claims, but on the political or military power of the claimants.
However, over time, the default rule became male primogeniture: later monarchs coming to the throne by exception to this rule went to great lengths to explain and justify going against these rules, and to prove their rivals illegitimate. Eventually, Parliament took control of succession.
Westeros/The Seven Kingdoms has no parliament, so it seems we are back to it being the one with the strongest army.
There is, however, one more potential spanner in the works [spoilers from the books]
Though he has yet to put in any appearance in the TV shows, in the books we have already seen the return of Jon Connington [hand of the king to Aerys II] along with a character (Young Griff) believed to actually be Aegon Targaryen, the surviving son of Rhaegar.
If proven, then he would be the legitimate heir, by the medieval male-preference primogeniture rules.
Note Reasoning for that assumption is because everything else in the series seems roughly modelled on medieval Britain, even down to the regional placement of the actor's accents, except for 'Scotland' North of the Wall, for which they have been using Scandinavian accents, presumably to not offend the Scots, & Dorne [Cornwall] which is the only one of the seven Kingdoms that doesn't appear 'British' at all.
Update after comments.
It would appear that the Targaryens have, since the Dance of the Dragons (129 -131 AC) used a method of agnatic primogeniture rather than male-preference.
From awoiaf: Targaryens
Since the Dance, House Targaryen has practiced a highly modified version of agnatic primogeniture, placing female claimants in the line of succession behind all possible male ones, even collateral relations.
Though that would still only [if at all, in an agnatic system] place Daenerys behind Jon in succession order if Jon's legitimacy was proven.
As we currently have a queen on the throne, as of S06E10, then I think we could say there is precedence for Daenerys' claim.
I still think it will come down to who has the most powerful army - though we know the plot will never be that simple, but it's out of scope to start wondering whether they'll join forces to fight the Night King.
One further point to ponder - and to which I don't know the answer as I'm no expert on agnatic primogeniture
...would Daenerys' marriage to Hizdahr zo Loraq give him precedence over her?
Succession to the British throne
A Wiki of Ice & Fire: